[TASK] Fix some code sanity issues and a reversed comparison logic