added 'end' to foreach in unparser.rb:set_layers