Documentation and code cleanup