Put macro in package. Fixed some issues. Still some linearization issues remaining.