Moved lots of bits around to make this a module
Nearly working with sqlalchemy and wtforms