A lot of refactoring: re-wrote all SQL queries to fetch data as arrays and not as objects. Moved calculation of 'total_votes' for a poll to the poll model, as well as the function to calculate the percentage of the options of a poll. Retested all functionality with AJAX.
Continue minor refactoring and cleaning up comments