Fixes provided by hien earlier today

Fixes provided by hien earlier today