further architectural changes, memory leak fixes