Runtime: fix off-by-one error in marshalling (fixes #176)