some bug fixes
merged from master
merged from master