Removed unused code and added some missing unit tests.