Improved performance of binfun when bsxfun is available and replaced repmat calls where appropriate