misc refactoring and updating examples