Updated ref.hpp, thanks Tom Spilman