Jonas' changes in this commit.