Fixed #764 and fixed #765