Some refactoring and preparing database.