fixes in models and database logic