Properly increment references where needed