Various performance and stability fixes.
SDL2 compatibility.