changed for-loops to use indexes rather than enhanced for-loops, fixed up locking [fixes #397]
Merge branch 'develop' of github.com:csound/csound into develop