Clean up and fixes.

Removed unnecessary code and made some fixes.