Merge pull request #869 from heuripedes/master

SDL fixes and improvements