Fixed bug where length is undefined, improvements to audio handling