Removed a lot of stuff, as the engine should be completed first. Code
is much cleaner, and does not segfault in strange places. States work
correctly and can be switched as you would expect.