Fixed #663, other minor issues