high dpi (retina/etc) support, mild refactoring