Fixed some infinity bugs