Fixed the localtime issue in sqlite and cleaned up the database tracking a bit