 package stdio {
   import flash.display.Sprite
-  import flash.events.UncaughtErrorEvent
+  import flash.events.*
   import flash.net.*
 
   public class Process extends Sprite {

    public function Process() {
      instance = this
      connect(function (): void {
        handle_uncaught_errors()
        main()
      })
    }

    public function get stdout(): OutputStream { return stdout_socket }
    public function get stderr(): OutputStream { return stderr_socket }

    private function listen_for_uncaught_errors(): void {
      loaderInfo.uncaughtErrorEvents.addEventListener(
        UncaughtErrorEvent.UNCAUGHT_ERROR,
        handle_uncaught_error_event
      )
    }

    protected function handle_uncaught_error_event(
      event: UncaughtErrorEvent
    ): void {
      event.preventDefault()

      if (event.error is Error) {
        warn((event.error as Error).getStackTrace())
      } else {
        warn(event.error)
      }

      exit(1)
    }

    private function connect(callback: Function): void {
