Fix/copy openproject errors

https://www.openproject.org/work_packages/3222.

Don't know if I got everything. Performance will (hopefully) get better in another PR.