Fix a start-command bug and refactor