some changes from the original branch

original commit: 488f83f50d2311ce2b460ecb03bd13b488d5b15d