modified code base to support flattened events and added flattening script