Clean up allocated resources

Signed-off-by: James Tasker <james_tasker1@hotmail.com>