Fixed #467, #1137, #1142