Edge-case writing bug fixes