Added some coments, code cleanup.