Fixed some runtime errors in Xcode dp5