Got alerts closing. Code has gotten a little hackneyed, though, and the scope has expanded a little. Will clean it up in the next commit.