Version tested with valgrind

- All testcases passes fine,
- valgrind doesn't show any notfreed or misused memory blocks