Move a few scraps that were not correctly moved to api.py in earlier commit