HB code almost complete. Added documentation. Moved a couple of utility functions from print.r to utils.r