Code cleanup. Regression tests pass!