Fixes for broken build on Mountain Lion + other fixes related to calls to the OT API.

Tested on Mountain Lion. Merging since the build is currently broken and this fixes that on my machine.