Fixed logical inconsistencies.