Fix migrations and reorganize the application