Post HW2

Revamped most of the logic.