improved logging and fixed deletion