cleaned main file parsing code

Cleaned up main file data parsing code, looks like it should work for
everything now, and it has been compressed into one method for now,
there may be some speed issues with the inner loop parsing the data,
since it checks 4 conditions each loop, which means a total of 2800
comparisons per file. Not an issue now since it is compiled server
side. but when local could be a source of error.