Improve migration functionality

Pull to Master