Move main loop actions to inline functions

And use memset() over bzero().
Basic Makefile