Moved running logic from main to classify method.

So now it's ready to be used from other clients as a lib. Also extra utility methods were added for calling from clients.