fixed two bugs that were preventing the finalize() function of the context manager from doing its cleaning up