Refactor general_write_handler some more