Added writer support for metadata + some exceptional case checking. Moved error-related string constants to separate file.