Removed unneeded code and fixes some unit tests