Some refactoring and added new attributes to DB