added handleEndEvent and handleGateway for representation compilation