Fix bugs (logging, debugging)