Updates to fix memoryleaks