Added assert. commented code, code cleanup