Fixed stuff and added more output for debug mode