Added local to some vars to try and fix a var clash
Version bumped from  0.5 to 0.5.1
Merge branch 'release-0.5.1'