start adding reference counter to resource management