diff --git a/src/include/ZMap/zmapFeature.h b/src/include/ZMap/zmapFeature.h
index a6e51b4987c805c6bb5cd0dc9744b1029a2532a7..8600d38acadd9ab3814e89193fe4a098804710db 100755
--- a/src/include/ZMap/zmapFeature.h
+++ b/src/include/ZMap/zmapFeature.h
@@ -25,9 +25,9 @@
  * Description: Data structures describing a sequence feature.
  *              
  * HISTORY:
- * Last edited: Jul 28 09:36 2005 (rnc)
+ * Last edited: Aug  9 11:51 2005 (edgrif)
  * Created: Fri Jun 11 08:37:19 2004 (edgrif)
- * CVS info:   $Id: zmapFeature.h,v 1.37 2005-07-28 08:36:38 rnc Exp $
+ * CVS info:   $Id: zmapFeature.h,v 1.38 2005-08-09 10:51:40 edgrif Exp $
  *-------------------------------------------------------------------
  */
 #ifndef ZMAP_FEATURE_H
@@ -142,8 +142,12 @@ typedef struct
  * QUITE A NUMBER OF ACCESS FUNCTIONS.... */
 
 
+
+/* We need some forward declarations for pointers we include in some structs. */
 typedef struct ZMapFeatureAlignmentStruct_ *ZMapFeatureAlignment ;
 
+typedef struct ZMapFeatureTypeStyleStruct_ *ZMapFeatureTypeStyle ;
+
 
 /* WARNING: READ THIS BEFORE CHANGING ANY FEATURE STRUCTS:
  * 
@@ -162,14 +166,16 @@ typedef struct ZMapFeatureAnyStruct_
 {
   GQuark unique_id ;					    /* Unique id of this feature. */
   GQuark original_id ;					    /* Original id of this feature. */
-
-
 } ZMapFeatureAnyStruct, *ZMapFeatureAny ;
 
 
-/* Holds a set of ZMapFeatureSet's.
- * Structure would usually contain a complete set of data from a server for a particular span
- * of a sequence. */
+
+/* Holds a set of data that is the complete "view" of the requested sequence.
+ * 
+ * This includes all the alignments which in the case of the original "fmap" like view
+ * will be a single alignment containing a single block.
+ * 
+ */
 typedef struct ZMapFeatureContextStruct_
 {
   GQuark unique_id ;					    /* Unique id of this feature. */
@@ -193,12 +199,20 @@ typedef struct ZMapFeatureContextStruct_
   ZMapMapBlockStruct sequence_to_parent ;		    /* Shows how this sequence maps to its
 							       ultimate parent. */
 
+
+  GList *feature_set_names ;				    /* Global list of _names_ of all requested
+							       feature sets for the context,
+							       _only_ these sets are loaded into
+							       the context. */
+
+  GList *styles ;					    /* Global list of all styles, some of
+							       these styles may not be used if not
+							       required for the list given by
+							       feature_set_names. */
+
   ZMapFeatureAlignment master_align ;			    /* The target/master alignment out of
 							       the below set. */
 
-  GList *types ;					    /* Global list of types, _only_ these
-							       types are loaded into the context. */
-
   GData *alignments ;					    /* All the alignements for this zmap
 							       as a set of ZMapFeatureAlignment. */
 
@@ -237,9 +251,10 @@ typedef struct ZMapFeatureBlockStruct_
 
 
 
-/* Holds a set of ZMapFeature's, note that the id for the set is the same as the style name for
- * the set of features. There is duplication here and probably we should hold a pointer to the
- * the style here.... */
+/* Holds a set of ZMapFeature's, note that the id for the set is by default the same name
+ * as the style for all features in the set. BUT it may not be, the set may consist of
+ * features with many types/styles. The set id is completely independent of the style name.
+ */
 typedef struct ZMapFeatureSetStruct_
 {
   GQuark unique_id ;					    /* Unique id for feature set used by
@@ -249,9 +264,6 @@ typedef struct ZMapFeatureSetStruct_
   ZMapFeatureBlock parent_block ;			    /* Our parent block. */
 
   GData *features ;					    /* A set of ZMapFeatureStruct. */
-
-  GQuark style_id ;					    /* Style for these features. */
-
 } ZMapFeatureSetStruct, *ZMapFeatureSet ;
 
 
@@ -302,6 +314,8 @@ typedef struct ZMapFeatureStruct_
 
   ZMapFeatureSet parent_set ;				    /* Our containing set. */
 
+  ZMapFeatureTypeStyle style ;				    /* style defining how this feature is
+							       drawn. */
 
   ZMapFeatureID db_id ;					    /* unique DB identifier, currently
 							       unused but will be..... */
@@ -369,7 +383,7 @@ typedef struct ZMapFeatureTypeStyleStruct_
   gboolean  frame_specific ;
   gboolean  show_rev_strand ;
 
-} ZMapFeatureTypeStyleStruct, *ZMapFeatureTypeStyle ;
+} ZMapFeatureTypeStyleStruct ;
 
 
 
@@ -398,7 +412,8 @@ ZMapFeature zMapFeatureFindFeatureInSet(ZMapFeatureSet feature_set, GQuark featu
 GData *zMapFeatureFindSetInContext(ZMapFeatureContext feature_context, GQuark set_id) ;
 
 
-ZMapFeatureContext zMapFeatureContextCreate(char *sequence, int start, int end, GList *types) ;
+ZMapFeatureContext zMapFeatureContextCreate(char *sequence, int start, int end,
+					    GList *styles, GList *feature_set_names) ;
 gboolean zMapFeatureContextMerge(ZMapFeatureContext *current_context_inout,
 				 ZMapFeatureContext new_context,
 				 ZMapFeatureContext *diff_context_out) ;
@@ -419,21 +434,33 @@ void zMapFeatureBlockDestroy(ZMapFeatureBlock block, gboolean free_data) ;
 
 ZMapFeature zmapFeatureCreateEmpty(void) ;
 gboolean zmapFeatureAugmentData(ZMapFeature feature, char *feature_name_id, char *name,
-				char *sequence, ZMapFeatureType feature_type,
-				int start, int end, double score, ZMapStrand strand,
-				ZMapPhase phase,
+				char *sequence,
+				ZMapFeatureType feature_type,  ZMapFeatureTypeStyle style,
+				int start, int end, double score, ZMapStrand strand, ZMapPhase phase,
 				ZMapHomolType homol_type_out, int start_out, int end_out,
 				GArray *gaps) ;
-GQuark zMapFeatureGetStyleQuark(ZMapFeature feature) ;
+
+GList *zMapStylesGetNames(GList *styles) ;
+
+
 ZMapFeatureTypeStyle zMapFeatureGetStyle(ZMapFeature feature) ;
+
+ZMapFeatureSet zMapFeatureGetSet(ZMapFeature feature) ;
+
+
 void zmapFeatureDestroy(ZMapFeature feature) ;
 
+
+
+
 ZMapFeatureSet zMapFeatureSetCreate(char *source, GData *features) ;
+
 ZMapFeatureSet zMapFeatureSetIDCreate(GQuark original_id, GQuark unique_id, GData *features) ;
 void zMapFeatureSetAddFeature(ZMapFeatureSet feature_set, ZMapFeature feature) ;
-ZMapFeatureTypeStyle zMapFeatureSetGetStyle(ZMapFeatureSet feature_set) ;
-void zMapFeatureSetDestroy(ZMapFeatureSet feature_set, gboolean free_data) ;
 
+char *zMapFeatureSetGetName(ZMapFeatureSet feature_set) ;
+
+void zMapFeatureSetDestroy(ZMapFeatureSet feature_set, gboolean free_data) ;
 
 ZMapFeatureTypeStyle zMapFeatureTypeCreate(char *name,
 					   char *outline, char *foreground, char *background,
diff --git a/src/zmapFeature/zmapFeature.c b/src/zmapFeature/zmapFeature.c
index aceca15b2d4abd96d9ac3850edd2431e42d67458..1b9fe5a25dbd672ee7c20c7c5ff63509201bf3cb 100755
--- a/src/zmapFeature/zmapFeature.c
+++ b/src/zmapFeature/zmapFeature.c
@@ -27,9 +27,9 @@
  *              
  * Exported functions: See zmapView_P.h
  * HISTORY:
- * Last edited: Jul 27 13:14 2005 (edgrif)
+ * Last edited: Aug  5 16:47 2005 (edgrif)
  * Created: Fri Jul 16 13:05:58 2004 (edgrif)
- * CVS info:   $Id: zmapFeature.c,v 1.19 2005-07-27 12:19:53 edgrif Exp $
+ * CVS info:   $Id: zmapFeature.c,v 1.20 2005-08-09 10:52:43 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -131,7 +131,8 @@ ZMapFeature zmapFeatureCreateEmpty(void)
  * are different for different features.
  *  */
 gboolean zmapFeatureAugmentData(ZMapFeature feature, char *feature_name_id, char *name,
-				char *sequence, ZMapFeatureType feature_type,
+				char *sequence,
+				ZMapFeatureType feature_type, ZMapFeatureTypeStyle style,
 				int start, int end, double score, ZMapStrand strand,
 				ZMapPhase phase,
 				ZMapHomolType homol_type, int query_start, int query_end,
@@ -147,6 +148,7 @@ gboolean zmapFeatureAugmentData(ZMapFeature feature, char *feature_name_id, char
       feature->unique_id = g_quark_from_string(feature_name_id) ;
       feature->original_id = g_quark_from_string(name) ;
       feature->type = feature_type ;
+      feature->style = style ;
       feature->x1 = start ;
       feature->x2 = end ;
       feature->strand = strand ;
@@ -437,7 +439,8 @@ void zMapFeatureBlockDestroy(ZMapFeatureBlock block, gboolean free_data)
 }
 
 
-ZMapFeatureContext zMapFeatureContextCreate(char *sequence, int start, int end, GList *types)
+ZMapFeatureContext zMapFeatureContextCreate(char *sequence, int start, int end,
+					    GList *types, GList *set_names)
 {
   ZMapFeatureContext feature_context ;
 
@@ -451,7 +454,8 @@ ZMapFeatureContext zMapFeatureContextCreate(char *sequence, int start, int end,
       feature_context->sequence_to_parent.c2 = end ;
     }
 
-  feature_context->types = types ;
+  feature_context->styles = types ;
+  feature_context->feature_set_names = set_names ;
 
   g_datalist_init(&(feature_context->alignments)) ;
 
diff --git a/src/zmapFeature/zmapFeatureUtils.c b/src/zmapFeature/zmapFeatureUtils.c
index ff0a24eda3484ad4d6db0210cacae6d69dfc1b3c..aae9dac83db7fa22199a484b35ac881d8fe512ef 100755
--- a/src/zmapFeature/zmapFeatureUtils.c
+++ b/src/zmapFeature/zmapFeatureUtils.c
@@ -22,13 +22,13 @@
  * 	Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
  *      Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk
  *
- * Description: Manipulates features.
- *              1
- * Exported functions: See zmapFeature.h
+ * Description: Utility routines for handling features/sets/blocks etc.
+ *              
+ * Exported functions: See ZMap/zmapFeature.h
  * HISTORY:
- * Last edited: Jul 28 09:37 2005 (rnc)
+ * Last edited: Aug  9 11:55 2005 (edgrif)
  * Created: Tue Nov 2 2004 (rnc)
- * CVS info:   $Id: zmapFeatureUtils.c,v 1.20 2005-07-28 08:38:22 rnc Exp $
+ * CVS info:   $Id: zmapFeatureUtils.c,v 1.21 2005-08-09 10:55:30 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -54,6 +54,7 @@ static void printFeature(GQuark key_id, gpointer data, gpointer user_data) ;
 static gboolean printLine(GIOChannel *channel, gchar *line) ;
 static gint findStyle(gconstpointer list_data, gconstpointer user_data) ;
 static gint findStyleName(gconstpointer list_data, gconstpointer user_data) ;
+static void addTypeQuark(gpointer data, gpointer user_data) ;
 
 
 /* This function creates a unique id for a feature. This is essential if we are to use the
@@ -151,43 +152,38 @@ gboolean zMapFeatureSetCoords(ZMapStrand strand, int *start, int *end, int *quer
 }
 
 
-GQuark zMapFeatureGetStyleQuark(ZMapFeature feature)
+
+ZMapFeatureSet zMapFeatureGetSet(ZMapFeature feature)
 {
-  GQuark style_quark ;
+  ZMapFeatureSet feature_set ;
 
-  style_quark = feature->parent_set->style_id ;
+  feature_set = feature->parent_set ;
 
-  return style_quark ;
+  return feature_set ;
 }
 
 
-
 ZMapFeatureTypeStyle zMapFeatureGetStyle(ZMapFeature feature)
 {
   ZMapFeatureTypeStyle style ;
-  GList *styles = feature->parent_set->parent_block->parent_alignment->parent_context->types ;
 
-  style = zMapFindStyle(styles, feature->parent_set->style_id) ;
-  zMapAssert(style) ;
+  style = feature->style ;
 
   return style ;
 }
 
 
-ZMapFeatureTypeStyle zMapFeatureSetGetStyle(ZMapFeatureSet feature_set)
+char *zMapFeatureSetGetName(ZMapFeatureSet feature_set)
 {
-  ZMapFeatureTypeStyle style ;
-  GList *styles = feature_set->parent_block->parent_alignment->parent_context->types ;
+  char *set_name ;
 
-  style = zMapFindStyle(styles, feature_set->style_id) ;
-  zMapAssert(style) ;
+  set_name = (char *)g_quark_to_string(feature_set->original_id) ;
 
-  return style ;
+  return set_name ;
 }
 
 
 
-
 /* Retrieve a style struct for the given style id. */
 ZMapFeatureTypeStyle zMapFindStyle(GList *styles, GQuark style_id)
 {
@@ -218,7 +214,32 @@ gboolean zMapStyleNameExists(GList *style_name_list, char *style_name)
 
 
 
+/* Retrieve a Glist of the names of all the styles... */
+GList *zMapStylesGetNames(GList *styles)
+{
+  GList *quark_list = NULL ;
+
+  zMapAssert(styles) ;
 
+  g_list_foreach(styles, addTypeQuark, (void *)&quark_list) ;
+
+  return quark_list ;
+}
+
+/* GFunc() callback function, appends style names to a string, its called for lists
+ * of either style name GQuarks or lists of style structs. */
+static void addTypeQuark(gpointer data, gpointer user_data)
+{
+  ZMapFeatureTypeStyle style = (ZMapFeatureTypeStyle)data ;
+  GList **quarks_out = (GList **)user_data ;
+  GList *quark_list = *quarks_out ;
+
+  quark_list = g_list_append(quark_list, GUINT_TO_POINTER(style->unique_id)) ;
+
+  *quarks_out = quark_list ;
+
+  return ;
+}
 
 
 
@@ -402,14 +423,14 @@ gboolean zMapFeatureStr2Strand(char *string, ZMapStrand *strand)
 
 gboolean zMapFeatureValidatePhase(char *value, ZMapPhase *phase)
 {
-  gboolean status = TRUE;
+  gboolean status = TRUE ;
 
-  *phase = ZMAPPHASE_NONE;
+  *phase = ZMAPPHASE_NONE ;
 
   if (zMapStr2Int(value, phase) != TRUE || *phase < 0 || *phase > 3)
-	status = FALSE;
+    status = FALSE ;
 
-  return status;
+  return status ;
 }
 
 
@@ -603,7 +624,7 @@ static void printFeatureSet(GQuark key_id, gpointer data, gpointer user_data)
 
   line = g_strdup_printf("\tFeature Set:\t%s\t%s\n",
 			 g_quark_to_string(feature_set->unique_id),
-			 (char *)g_quark_to_string(feature_set->style_id)) ;
+			 (char *)g_quark_to_string(feature_set->original_id)) ;
 
   /* Only proceed if there's no problem printing the line */
   if ((dump_features->status = printLine(dump_features->channel, line)))