Replaced many raw pointers by references. Pointers are evil.