Fixed some logical errors.