added sqlite support, and some bugfixes