Added DEBUG

Also moved ts-related vars to global