Various typo and small code upgrades