resolved most of memory management inssues