work in progress
merge with upstream