Address some TODOs. Use options rather than global variables for configuration, with defaults. Clean up documentation warnings.