Fix logic issues.