rewrote everything so that all SDL calls occur in the same thread