Don't init env if sampleRate isn't set

Also cleaned up a little code.