fix for #336
- improve path handling
Merge pull request #342 from guwirth/bugfix/336_valgrind

fix for #336