hiDPI support. miscellaneous refactoring.