Fixed the bug mentioned in #678 (comment).