Refactoring Widget base class for minimizing memory usage