Copying some stuff from former tsconsole.