Some refactoring.
Added migrations.