optimizer fixes
error detection and comments handling in optimizer