Refactored a little and added handling of limit in query.
Merge pull request #21 from szilardhuber/master

Refactored a little and added handling of limit in query.