Fix undefined index/undefined offset
Remove unnecessary if statements
Fix undefined constant
Fix undefined index
Fix undefined index