cleaned up sql queries, minor changes to application structure, added function for fetching query results