add threads and context functions for the game