some refactoring, fixed whitespace handling
initial commit for a1q5