Add comments to statemachine.js