Change global options structure from array to object
Fix some global variables