Migrations added and defensive code added