WIP. Code cleanup. Doc enhancements.