fix segfault #515
Merge branch 'bugs/515'