Updated with code from pagews 14-15. 16 comes next.