Some more code cleanup and comments