[WIP] Refactor MSM

done.