More core engine stuff and some tests.