Restructured for readability and removal of magic constants

The entire source file except for test code was rewritten to:

  1) Add semantic macros for magic integer constants
  2) Avoid repeating the internal binary definitions (DRY)
  3) Use << ?MACROS >> to make binary structures readable
  4) Consistently use /unsigned for pointers and sizes
  5) Test all terminal cases in recursive functions last
  6) Add log functions for reporting binary dictionaries
  7) Add versioning for the internal binary format