added more macros for writing plugins, and restructured function composition