added some magic, bug fix for deletion (still wip)