Implement basic reference counting