Minor bugfix and also a slight cleanup of some duplicated code.
Minor documentation fix