trivial code changes for non-trivial performance improvement
cleaning up comments per @kjetilk and indentation per @kasei