Fixed #498 and worked on #494