Fixed support for references and proper string lengths