emulator: flush output and fix minor compilation issues