Macro support added. Closes #37. See issue for details. Had to move API into its own module.