more cleanup. found a strange bug, but it was there in the original