Added commenting and did cleanup and small fixes