added proper parent checks in delete functions after found bug where passing n when should have passed p