Load main file from package only if it is valid

Otherwise fallback to internal implementation.