This function has really blown my mind, in a sense that I'd struggle to change things or fix bugs in this. It's well documented, and all of the documentation makes sense, so there's probably nothing you can do. The only thing I can think about is doing a summary of the steps that will be taken in this function in the method documentation.