Mweb 965

Do not merge
Please merge changes from the palantir maintenance script before refactoring this part