Cleanups and minor corrections. Tests passed.