finalizing changes made to the context manager
I guess before it was pretty broken... fixed it