Fixed a few build errors here and there, and updated for Xcode 4