First major part of reducing dependence on macros

It's probably not buildable on VS2012 (or 2013?) any more.