fixed issue #679, #682, #683, #684, #689