Replaced Engine class with State struct and moved out all methods.