Some more fixes and removed unused code