Build fixes

This gets us part of the way along to fixing #22. My main goal was to fix the build, we can start looking at how to make things prettier later.

I also got rid of some code duplication using macros in the vector module. Now that macros can expand to multiple definitions we can start to clean up lots of the old code using macros - this is just a start.