Lots more shuffling. Moved monitor stuff to it's own header and
source (monitor.{h,c}. Added a bit more structure etc.