Added tests and cleanup.