Edited the code and write-up from last week with corrections.