cleanup and documentation
and bug fixes.