Refactoring the dat file loading, made it more flexible