Engine bugfixes