Made small improvements based on code analysis.