Port to Maverics.
Fix cpplint.
Move error handling code to avoid undefined behavior.
Merge pull request #833 from gwtnb/mavericks

Port to Maverics.