added max_depth to set up better graphics
replaced parser use of malloc with custom allocator