change %define to %global

move all variables to top

clean spaces and header order