File writer / get_message_fn bugfix and better error handling