4.0

Code well commented, ready for submisison.
Ran test traces again and matched all output.