Batch of small tweaks

Mostly style and a few small internal API tweaks.