Modernized code a little bit, but didn't find any errors.
Modernized code.