Some minor code cleanup and documentation