loading and saving to db, bugs fixed