Moved all state block code into context as part of an effort to more centrally manage calls to the API. Also made it so the context can only be used on the thread it is created on to better facilitate multithreaded rendering properly later.