Did some changes to arcitecture
Finally a real fix to bug with memory leak