improve error handling and avoid race condition
notify on stderr when out of spinlock
handle more error conditions
do not call dir_exit_method() if dir_enter_method() returns 0