Refactored

Separated command line/single run code with core mapping and running
logic.
Fixed some code that did not conform to ruby style guidlines