fixed issue #548, #562, #549, #547, #543