improved memory management
fixed trend to json conversion
improved mem management in grpany code