Added SQLite support and loads of other changes