Do not call references unless needed. Fixes #1833