Further code cleanups
Some more cleanups and docs
More (correct) tests