Add call to cap_enter() and additional debug output