Some fixes
Merged upstream