fixes, better deletion function, better handling of deletion