Fix xdebug error and clean up