Refactor
Use volatile for ticks
Fix Makefile