Move RS migration code to separate module