minor changes

many small improvements to the code