Refactor Makefile and modules