I was planning on optimizing this once we had everything else correct, but then I just forgot; so I'll take a look.