Added support for files, cleaned up