Use presumably faster cast using reference (#3472)