pass references instead of pointers, use const (#3472)