Some documentation and code cleanup