Another round of major bug fixing. Ended up refactoring some code in the audio library.