Get rid of global non-readonly variables within the library

This makes sure separate instances of the codec within a process don't interfere with each other in any way.