Added retmax functionality to allow paging
Refactored reading the POST a bit