Added serialization of references

Fixes #528