Improved and generalized abstract UIElement class