Cleaned up stat table build code and moved it into the data folder