diff --git a/xml2xslt.xsl b/xml2xslt.xsl
index 1ec53bd..be4131d 100644
--- a/xml2xslt.xsl
+++ b/xml2xslt.xsl
@@ -60,7 +60,24 @@
 
 		
 		
+		
+		
+        
+            
+% Avoid option clash if document class already loaded it.
+\makeatletter
+\@ifpackageloaded{hyperref}{}{\usepackage{hyperref}}
+\makeatother
 
+% Safer to specify the hyperref options directly rather than relying on
+% the default hyperref.cfg, as XeLaTeX seems to ignore it :(.
+\hypersetup{pdfpagemode=UseNone,colorlinks,urlcolor=blue,citecolor=blue,%
+            linkcolor=blue,breaklinks}
+
+        
+				
 		
@@ -83,7 +100,8 @@
 			
 			
 		
-
+	    
+	    
 		
@@ -142,16 +160,9 @@
 
 					
 
-					
-% Safer to specify the hyperref options directly rather than relying on
-% the default hyperref.cfg, as XeLaTeX seems to ignore it :(.
-\usepackage[	pdfpagemode=UseNone,%
-				colorlinks,%
-				urlcolor=blue,%
-				citecolor=blue,%
-				linkcolor=blue,%
-				breaklinks	]{hyperref}
+                    
 
+					
 \renewcommand{\ttdefault}{blg}
 
 				
@@ -180,16 +191,9 @@
 
 					
 					
-					
-% Safer to specify the hyperref options directly rather than relying on
-% the default hyperref.cfg, as XeLaTeX seems to ignore it :(.
-\usepackage[	pdfpagemode=UseNone,%
-				colorlinks,%
-				urlcolor=blue,%
-				citecolor=blue,%
-				linkcolor=blue,%
-				breaklinks	]{hyperref}
+                    
 
+					
 \defaultfontfeatures{Mapping=tex-text}
 \setmainfont{TeX Gyre Pagella}
 \setmathsfont(Digits){TeX Gyre Pagella}
@@ -309,10 +313,17 @@
 			
 				
 				pdf
+				            
 				
-				
 				
 					
@@ -324,6 +335,20 @@
 				    }
 
 				
+				
+				
+				
+					
+\def\LaTeXOptions{
+                    
+				    }
+
+				
 
 				
 				
@@ -336,12 +361,17 @@
 % THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT!
 
 
+							
 							
 							
 \PassOptionsToClass{\LaTeXOptions}{\DocumentClass}
 \documentclass{\DocumentClass}
 
-\usepackage[margin=1in]{geometry}
+% Avoid option clash if document class already loaded it.
+\makeatletter
+\@ifpackageloaded{geometry}{}{\usepackage[margin=1in]{geometry}}
+\makeatother
+
 \usepackage{multirow}
 \usepackage{graphicx}
 \usepackage{verbatim}       % needed for \verbatiminput
@@ -363,19 +393,12 @@
 							
 \newenvironment{answer}{\par\vspace{0.5em}\itshape}{\normalfont\vspace{1.5em}}
 
-% Listings setup. We preload the most obviously like languages to speed things
+% Listings setup. We preload the most commonly used languages to speed things
 % up. Other languages will still work, just not quite as quickly.
 \lstloadlanguages{Oracle}
 \lstset{basicstyle=\ttfamily,basewidth=0.5em,escapeinside={(@}{@)},
 	showspaces=false,showstringspaces=false}
 
-% Environment for worksheet exercises.
-\newcounter{exercise}
-\setcounter{exercise}{0}
-\newenvironment{exercise}%
-	{\noindent\refstepcounter{exercise}\begin{boxedminipage}{\columnwidth}\textbf{Exercise \theexercise: }}%
-	{\end{boxedminipage}}
-