Massive changes. Most of them related to saving to database