Fixed INF bug, made code more correct.