Code commented, tested.