Hw7 memory management

Code is functioning well and should now be merged with master