Some cleanup, added test.