refactor api, control and postback events