Partial fix debugger for multithreaded environment

    * Fixes crashing observed when trying to use debugger

    * Various refactoring whitespace fixes