Some smallish fixes
Considerable hacking