commit with final changes with all test cases and memory leaks removed