Cleanup and added codec context closing