Added sane logging and setting of debug levels