remove_empty_and_bad, intermediate, works in order, todo: remove empty