Removed unused code. Added tests.