Added ratelimit and more comments

The function ratelimit checks for the number of requests left for the
app