Added support for preview generation and corrected library() calls