fixes #1366
mostly fixes #1339
fixes #1067