Removes empty elements as much as possible.