Further refinements

A little more thorough with range-checking and organized the
macros in src/CMakeLists.txt a bit more logically.