Removed dead code, and corrected more errors