Lots of Comments added, and code cleaned up.

Still some missing comments and scrap code lying around. This should be
good enough.