Fixed some memory leaks
Define _GNU_SOURCE so I can get kill() in ubuntu