A lot of bugfixes related to recent changes.