Added all code from lecture 2.