cleanups. Fixed memory leak in elephant example