Finished the extra credit (and tidied up some loose ends)