This commit fixes several critical issues.