Fix a few CTF write bugs