Studies in model-based diagnosis