Most of assignment 2 and initial part of assignment 3