Debug 4

Added documentation, further incremental clean up.