Fixed #544 and fixed #827