Fixed #687 and fixed #712