Fix API debugging issues mentioned in #283

Note these are untested changes, written in the github UI. I don't have the appropriate system to check these changes on. =)