added pretty printing
minor changes
modified classes for easier refactoring and further modifications