Code for TCP's Tutorials 46-51