I changed how this worked quite a bit (hopefully for the better). Test added too although there's not much left to test now.