Adding rudimentary context switching (multithreading)