Fixed bug mentioned in #1024