Some refactoring and flow changes to solve issue 36.

Tries to expose the SQLiteExceptions to the end user, and at the same time fixes #36.