Some minor bug fixes in Engine