Fix #420 & refactor machine.New