documentation and code cleanup