Cleanp. Move some global and extern variables to proper spot
Inline function
Formating cleanup
Removing trailing space