Small optimization

Fixes #1216