minor mem managment fixes