Merge with @desunit changes and additional fixes in order for the tests to work.