Smarter handling of files

See line comments for more information
Expanded to reflect new functionality
Cleaned up some whitespace
0.0.5: Add support for multiple filename\'s prefixes