Index: cpp/frams/genetics/fB/fB_conv.cpp
===================================================================
--- cpp/frams/genetics/fB/fB_conv.cpp	(revision 780)
+++ cpp/frams/genetics/fB/fB_conv.cpp	(revision 797)
@@ -1,2 +1,6 @@
+// This file is a part of Framsticks SDK.  http://www.framsticks.com/
+// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
+// See LICENSE.txt for details.
+
 #include "fB_conv.h"
 
@@ -89,5 +93,14 @@
 			continue;
 		}
-		fH_Handle *handle = convertCharacterToHandle(gene[2], dims, start, end, ranges);
+		int hclasspos = 2;
+		if (gene[2] == '"')
+		{
+			hclasspos--;
+			if (!getNextCharId(gene, hclasspos))
+			{
+				return "";
+			}
+		}
+		fH_Handle *handle = convertCharacterToHandle(gene[hclasspos], dims, start, end, ranges);
 		ParamEntry *tab = creature.getParamTab(handle->type);
 		void *obj = ParamObject::makeObject(tab);
@@ -97,13 +110,38 @@
 
 		int propindex = 0;
-		int z = 3;
+		int z = hclasspos;
+		if (gene[z] == '"')
+		{
+			z--;
+			if (!getNextCharId(gene, z))
+			{
+				delete handle;
+				ParamObject::freeObject(obj);
+				return "";
+			}
+		}
 		endoffset = 0;
 		if (gene.indexOf("zz", 0) != -1) endoffset = 2;
+		int nclassdefcount = 1;
 		while (z < gene.len() - endoffset)
 		{
-			if (processNextLetter(creature, handle, par, gene, propindex, z, ranges) == -1)
-			{
-				logMessage("GenoConv_fBH", "convert", LOG_WARN, "Property of fH could not be parsed");
-			}
+			if (processNextLetter(creature, handle, par, gene, propindex, z, ranges, nclassdefcount) == -1)
+			{
+				logMessage("GenoConv_fBH", "convert", LOG_ERROR, "Property of fH could not be parsed");
+				delete handle;
+				ParamObject::freeObject(obj);
+				return "";
+			}
+		}
+		if (handle->type == fHBodyType::NEURON && propindex < par.getPropCount())
+		{
+			SString nclass;
+			if (!getNeuroClass(gene, nclass, nclassdefcount))
+			{
+				delete handle;
+				ParamObject::freeObject(obj);
+				return "";
+			}
+			par.setStringById(FH_PE_NEURO_DET, nclass);
 		}
 		handle->loadProperties(par);
@@ -132,5 +170,53 @@
 }
 
-int GenoConv_fBH::processNextLetter(fH_Builder &creature, fH_Handle *&currhandle, Param &par, SString gene, int &propindex, int &i, std::vector<IRange> ranges[3])
+bool GenoConv_fBH::getNextCharId(SString genotype, int &i)
+{
+	i++;
+	if (genotype[i] == '"')
+	{
+		int nextid = i + 1;
+		do
+		{
+			nextid = genotype.indexOf('"', nextid);
+			if (nextid == -1)
+			{
+				return false;
+			}
+			nextid++;
+		}
+		while (genotype[nextid] == '"');
+		i = nextid;
+	}
+	return true;
+}
+
+bool GenoConv_fBH::getNeuroClass(SString gene, SString &def, int nclassdefcount)
+{
+	SString lastdef = "N";
+	int nclass = 0;
+	int pos = 0;
+	while (nclass < nclassdefcount)
+	{
+		pos = gene.indexOf('\"', pos);
+		if (pos == -1)
+		{
+			def = lastdef;
+			return true;
+		}
+		pos++;
+		SString currdef;
+		if (gene.indexOf('\"', pos) == -1 || !gene.getNextToken(pos, currdef, '\"'))
+		{
+			def = lastdef;
+			return false;
+		}
+		lastdef = currdef;
+		nclass++;
+	}
+	def = lastdef;
+	return true;
+}
+
+int GenoConv_fBH::processNextLetter(fH_Builder &creature, fH_Handle *&currhandle, Param &par, SString gene, int &propindex, int &i, std::vector<IRange> ranges[3], int &nclassdefcount)
 {
 	if (propindex >= par.getPropCount())
@@ -147,5 +233,6 @@
 		par.setDefault();
 		propindex = 0;
-		i++;
+		if (!getNextCharId(gene, i))
+			return -1;
 		return 0;
 	}
@@ -166,12 +253,19 @@
 			}
 			propindex++;
-			i++;
+			if (!getNextCharId(gene, i))
+				return -1;
 			return 0;
 		}
 		else if (currhandle->type == fHBodyType::NEURON && *par.id(propindex) == 'd')
 		{
-			//TODO: handle neuron classes and properties
+			//When 'd' property appears for i-th element in gene, the method
+			//looks for i-th neuron definition
+			SString nclass;
+			if (!getNeuroClass(gene, nclass, nclassdefcount)) return -1;
+			par.setString(propindex, nclass);
 			propindex++;
-			i++;
+			nclassdefcount++;
+			if (!getNextCharId(gene, i))
+				return -1;
 			return 0;
 		}
