Fixing a memory leak, fixing Makefile and initializing connection