Assorted changes: bugfix, single-threaded mode

(Happy to submit this as separate pull requests if preferable.)

Mostly minor tweaks, except for the single-threaded mode (written for an application that requires synchronous calls but can't use threads).