some refactoring and ground work for tab completion