Fixed #569 and fixed #576