SDL: Make the code more platform-agnostic and cleaner.