Implemented rate limiting.

* The previous commit's code did not work and needed quite a bit of
  tweaking to get running correctly.
Added rate limiting code to /check endpoint.