code cleanup and replacing qDebug() with std clog/cerr/cout