Various additions

Added safe function declaration, reference preservation, and tweaked some code examples.