Fix variable use before definition
Fix incorrect logger usage
Fix parse errors causing duplicate messages