Refactor SCM scripts