copied fixes from https://github.com/hyakugei/UIToolkit/commit/3dc80eb86133e03ab0bfdf09ed60a28fac1db010