changer cerr to cout in debug messages since they are dissapearing somewhere