Work around some platform differances, and fix some bugs with the internal window size not being updated. Code runs somewhat on both Linux and Windows.