I've made the required changes and it all seems to work. Thanks for questioning me on it
As I suspected, I had solved the difficult problems already due to the "Use formatted title for sorting" option, as there were a lot of bugs with that after I introduced it, so I just had to insert a little extra code for the custom sort title.
