Completed question 10. Some speed improvements, cleanup and comment clarification on previous problems.