Flattens the structure of edit action and removes trailing whitespaces