added better dynamic handling of extensions