Use libsndfile for wav output
Minor fixes