more organised Main class

+ added shutdown hook