Fixing bugs to get migration working