References Issue #4

Refactored the code in order to make it easier to support endless pagination.