Moved untested code into XCode and fixed errors