Some minor improvements to argument handling and docs. Patches 2 and 3 are optional, they have zero functional change, but IMO make the code easier to follow for future workers.