Added detailed option for output; broke up classify() code into functions; added comments to classify() code.