General code quality and documentation improvements