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