refactor client-side code for better organization

Also include basic audio environment