Converting some text to lowercase caused range errors. I don't really know what I'm doing here, so I replaced the code with this answer from StackOverflow: <https://stackoverflow.com/a/21395>. It works now, let's hope it stays that way.