Moved all query routines into Database class