CSRF support
DB setup fix
Code tidy