more linething enhancements and some refactoring