FIX using C++ references instead of pointers