Completed: #6, and some minor bug fix