ENH: Create VALID_EXTENSION global variable
FIX: Cleaner flattening + unique value finding
DOC: Add comments to private functions.