Fixed condition in add_ref
Fixed local push bugs