added CostMatrix support
fixed documentation