adding ref counting class
fixing compilation issue in certain cases