Add code cleanup and documentation improvements