Fixed the way brackets are added to id's and names - they only need to be added if the value is not nil