Append missing defines
Refactored SDL interface
Set limit to unrolling functions
Cleanup thread function