Fixed debug pause after svg reload.
Also some refactoring