Fixed 1 bug, but there is a more subtle one in there somewhere