Add FileList class, use it to simplify code. Untested.