updated with changes from master
implemented fixes from master