Added render context and moved some of the functionality from window into it.