Removed dead code and fixed broken tests