Fix code and add makefile