Fixed intelligent file detection
Updated formatting to conform to pep8