Fix logic error for offset, and cast query params as integers.
Fix logic error for offset, and cast query params as integers.

opentechinstitute/piecewise,critzo/piecewise,opentechinstitute/piecewise,critzo/piecewise,critzo/piecewise,critzo/piecewise,opentechinstitute/piecewise,opentechinstitute/piecewise