Adds recording to a wav file of initial samples. Also fixed some errors in code (mostly caused by copying around things).