indentation cleanup and better handling of empty elements