Changing cout to cerr where needed