some warning fixes and general sdl optimization
Merge branch 'RicTemplateBranch'
Again master merged to my ugliness