Refactored logic to speed up queries, and reorganized code to be more

readable