multiple improvements
merged with upstream