Some cleanups and more tests