Makes delete function delete locally as well
Bugfixes in delete function