Fixed memory bug and added makefile