Fixes to the emulator
Fixes on the algorithm, which is now almost working. Even with bugs, it performs better than the original one, though.
Fixed remaining issues on the algorithm; slightly touched the output (but it needs an overhaul...)