Updated the patch and included documentation. It wasn't clear to me how to write a test for this. I couldn't spot any tests for the surrounding variables, but I might be missing something. If this is important, please let me know where I should add them. -- Kristian