Added a bit of parsing to remove empty elements if possible