Forked and modified in order to build in xcodeproj.