Fix exception throwing
Fix warnings.