Bug fixing and improvements
Major refactoring; fixes bugs, improves reliability and manages audio gain and loss