Code cleanup.

Removed unused code.

Put XCode in hard-mode and fixed most of the errors.