API and error handling cleanups

--HG--
branch : HEAD
15 files changed