Code was refactored in order to make easier an integration with a GUI.