Huge refactoring, separated classes and main run script into different files.