Added basename and array_diff helpers
Refactored optimizer