Various fixes and minor mods