Refactored code, improved logging, added a run script