Changed how before_migrate and after migrate are called to see if it makes semaphore happy