Added comments and cleand up code.