Replace some macros with inline functions...

* Allows the compiler to check types
* Produces much clearer error messages if something goes wrong