Improve globals management and fix Makefile