Some cleanup and renaming some j's to i's