Fix issue #18, memory leak bug

Fix memory leak caused by setting `instruments = []` rather than `instruments.length = 0`. This is a bugfix for issue #18.