A little bit more testing, but I think this is completely working.