Fix bug where cache would be created before calendar
Fix big bug where getting rows wouldn't ever close the db connection

involved rewriting a lot of db code