add database hooks
Cleaned up some stuff