finalize emulator, some bugs though