some fixes and improvements
merge conflicts