Fixed several errors and warnings.