Move db related stuff into models, minor css tweaks