Small bugfix on issue #507