Fix up doc strings, simplify some functions, etc.