Some cleanups, more test coverage