Changes from upstream MG-SDL2