Added SQLite support and fixed up a few things with refactoring / etc