some formatting changes
add regex to remove some empty nodes