Error cleanup.
Abstracted database handling.