There are a lot of places in this library that can be refactored and simplified. For instance, the load_xdf() method is unnecessarily long and complicated, and contains plenty of duplicate pieces of code. Re-write the methods as concisely as possible.