Add support for custom actions, refactor macro

Change-Id: I95198dca04ac69dc52decb030fd8f2b8a8299791