Fixes and more fixes

Improvements, typos and fixes to make code more compatible