Fixed a couple of segfaults and made Free a seperate function