compile-move-schemas and rearrange code