Refactor and code/documentation cleanup.