Fixed maxDepth code, misc. changes.

Sorry for the sloppy commits.  I'm still
trying to clean up the code.