added code to test duplicate and nested element conditions and store in metadata, as well as fix bug for BED inputs without a trailing newline