update, refactor, and test audio handling

and fix a few misc bugs