WIP, see the description of the PR under "Issues to be solved"