Avoiding memory leaks

Signed-off-by: Chris Warrick <kwpolska@gmail.com>