Replace pointers by references where possible