Fixed #828 and fixed #829