Rebase, rework and update Makefile.