refactoring of locals and a few other things (including style changes)