flush out documentation and clean up code