Code from lecture 13 and 14.