fixed memory leaks; added some tests
del gi
new gi