Way less globals

Lets see if the commit comments appear here
Sure, lets minimize the changes in this patch.