Made the database code look nicer
Added basic support for hooks & callbacks