Replaced stack_alloc with helper routine in reader.
Fixed mdserver-specific code section.