Fix: Fixed some smaller bugs such as leaks and performance improvements.
This is a first commit to correct minor problmes reported by Denis Denisov. There is likely another commit to correct some more such problems. Thank you Denis Denisov.
Showing with 57 additions and 42 deletions