Minor bugfixes

* Better error messages
* Support for large databases
* Performance improvement