Refactors and make the makefile work again