More bugfixes.

Database now gets destroyed.
2.2 compatible query method is used.