Some refactoring and fixed mis-spellings