fixed delete functionality. various bugs