port makedist fixes from master