Fixed some bugs and added sqlite backend.