Bug fixes to Engine class