Change 'write' to 'emit'; adjust some other names for PEP8.