diff --git a/index.html b/index.html
index ca27133db841204bcb7e538a32dfc5be12342d44..328b67d46eab839784f0d36821ac526778af393e 100644
--- a/index.html
+++ b/index.html
@@ -44,6 +44,7 @@
     <script src="js/fea/DmaNode.js"></script>
     <script src="js/fea/DmaBeam.js"></script>
     <script src="js/fea/DmaCell.js"></script>
+    <script src="js/fea/DMACellFreeform.js"></script>
     <script src="js/fea/DmaCellOcta.js"></script>
     <script src="js/fea/DmaCellTetra.js"></script>
     <script src="js/fea/DmaCellOther.js"></script>
diff --git a/js/fea/DMACellFreeform.js b/js/fea/DMACellFreeform.js
new file mode 100644
index 0000000000000000000000000000000000000000..4bc11cf2f509884b4fbada82e24574aaba39af3d
--- /dev/null
+++ b/js/fea/DMACellFreeform.js
@@ -0,0 +1,180 @@
+/**
+ * Created by aghassaei on 4/14/15.
+ */
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////FREEFORM SUPERCLASS////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+
+function DMAFreeFormCell(indices, scale, parentCellPos, parentCellQuat, direction, parentType){//no rigid lattice structure for cells
+    this.parentPos = parentCellPos;
+    this.parentQuaternion = parentCellQuat;
+    this.parentDirection = direction;
+    this.parentType = parentType;
+    DMACell.call(this, indices, scale);
+}
+DMAFreeFormCell.prototype = Object.create(DMACell.prototype);
+
+DMAFreeFormCell.prototype._calcPosition = function(){//todo this might not be necessary - put in lattice
+    var position = {};
+    var zScale = dmaGlobals.lattice.zScale();
+    position.x = this.parentPos.x+this.parentDirection.x*zScale/2;
+    position.y = this.parentPos.y+this.parentDirection.y*zScale/2;
+    position.z = this.parentPos.z+this.parentDirection.z*zScale/2;
+    return position;
+};
+
+DMAFreeFormCell.prototype.calcHighlighterPosition = function(face){
+    var direction = face.normal.clone();
+    direction.applyQuaternion(this.cellMesh.quaternion);
+    var position = this.getPosition();
+    position.add(direction.clone().multiplyScalar(this.zScale()/2));
+    return {index: _.clone(this.indices), direction:direction, position:position};
+};
+
+DMAFreeFormCell.prototype.toJSON = function(){
+    var json = DMACell.prototype.toJSON.call(this);
+    _.extend(json, {
+        parentPosition: this.parentPos,
+        parentOrientation: this.parentQuaternion,
+        direction: this.parentDirection,
+        parentType: this.parentType,
+        type: this.getType()
+    });
+    return json;
+};
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////OCTA///////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+
+function DMAFreeFormOctaCell(indices, scale, parentCellPos, parentCellQuat, direction, parentType){
+    DMAFreeFormCell.call(this, indices, scale, parentCellPos, parentCellQuat, direction, parentType);
+}
+DMAFreeFormOctaCell.prototype = Object.create(DMAFreeFormCell.prototype);
+
+DMAFreeFormOctaCell.prototype._doMeshTransformations = function(mesh){
+
+    if (!this.parentDirection) {
+        this.parentDirection = new THREE.Vector3(0,0,1);
+        this.parentQuaternion = new THREE.Quaternion();
+        this.parentPos = new THREE.Vector3(0,0,0);
+    }
+    var direction = this.parentDirection.clone();
+    var zAxis = new THREE.Vector3(0,0,1);
+    zAxis.applyQuaternion(this.parentQuaternion);
+    var quaternion = new THREE.Quaternion().setFromUnitVectors(zAxis, direction);
+    console.log(quaternion.clone());
+    quaternion.multiply(this.parentQuaternion);
+
+    var zAlignment = direction.sub(zAxis).length();
+    if ((this.parentType == "octa" && zAlignment < 0.1) || this.parentType == "tetra"){
+        console.log("yes");
+        var zRot = new THREE.Quaternion().setFromAxisAngle(this.parentDirection, Math.PI);
+        zRot.multiply(quaternion);
+        quaternion = zRot;
+    }
+
+    mesh.quaternion.set(quaternion.x, quaternion.y, quaternion.z, quaternion.w);
+};
+
+DMAFreeFormOctaCell.prototype._initParts = function(){
+    var parts  = [];
+    parts.push(new DMAOctaTroxPart(1, this));
+    return parts;
+};
+
+DMAFreeFormOctaCell.prototype.getType = function(){
+    return "octa";
+};
+
+DMAFreeFormOctaCell.prototype._getGeometry = function(){
+    return unitFaceOctaGeo;
+};
+
+DMAFreeFormOctaCell.prototype.xScale = function(scale){
+    if (!scale) scale = this.getScale();
+    return scale;
+};
+
+DMAFreeFormOctaCell.prototype.yScale = function(scale){
+    return this.xScale(scale)/2*Math.sqrt(3);
+};
+
+DMAFreeFormOctaCell.prototype.zScale = function(scale){
+    if (!scale) scale = this.getScale();
+    return scale*2/Math.sqrt(6);
+};
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////TETRA//////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+
+var unitCellGeo2 = new THREE.TetrahedronGeometry(Math.sqrt(3/8));
+unitCellGeo2.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI/4));
+unitCellGeo2.applyMatrix(new THREE.Matrix4().makeRotationX((Math.PI-Math.atan(2*Math.sqrt(2)))/2));
+
+function DMAFreeFormTetraCell(indices, scale, parentCellPos, parentCellQuat, direction, parentType){
+    DMAFreeFormCell.call(this, indices, scale, parentCellPos, parentCellQuat, direction, parentType);
+}
+DMAFreeFormTetraCell.prototype = Object.create(DMAFreeFormCell.prototype);
+
+DMAFreeFormTetraCell.prototype._doMeshTransformations = function(mesh){
+    var direction = this.parentDirection.clone();
+    var zAxis = new THREE.Vector3(0,0,1);
+    zAxis.applyQuaternion(this.parentQuaternion);
+    var quaternion = new THREE.Quaternion().setFromUnitVectors(zAxis, direction);
+    quaternion.multiply(this.parentQuaternion);
+
+    var zComponent = direction.sub(zAxis).length();
+    console.log(zComponent);
+    console.log(new THREE.Euler().setFromQuaternion(quaternion));
+    if (zComponent >= 1){
+        console.log("yes");
+        console.log("");
+        var zRot = new THREE.Quaternion().setFromAxisAngle(this.parentDirection, Math.PI);
+        zRot.multiply(quaternion);
+        quaternion = zRot;
+    }
+
+    var eulerRot = new THREE.Euler().setFromQuaternion(quaternion);
+    mesh.rotation.set(eulerRot.x, eulerRot.y, eulerRot.z);
+};
+
+DMAFreeFormTetraCell.prototype.getType = function(){
+    return "tetra";
+};
+
+DMAFreeFormTetraCell.prototype._initParts = function(){
+    var parts  = [];
+    parts.push(new DMATetraTroxPart(1, this));
+    return parts;
+};
+
+DMAFreeFormTetraCell.prototype.xScale = function(scale){
+    if (!scale) scale = this.getScale();
+    return scale;
+};
+
+DMAFreeFormTetraCell.prototype.yScale = function(scale){
+    return this.xScale(scale)/2*Math.sqrt(3);
+};
+
+DMAFreeFormTetraCell.prototype.zScale = function(scale){
+    if (!scale) scale = this.getScale();
+    return scale*2/Math.sqrt(24);
+};
+
+DMAFreeFormTetraCell.prototype._getGeometry = function(){
+    return unitCellGeo2;
+};
+
diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js
index cb00ab3429ed8ce41569b2125bf16bbcbe6bc758..8e2ae2a1bb12cd00a34aecf7f1ee99da94254ed6 100644
--- a/js/fea/DmaCell.js
+++ b/js/fea/DmaCell.js
@@ -257,47 +257,4 @@ DMACell.prototype.toJSON = function(){
     };
     if (this.parts) data.parts = this.parts;
     return data;
-};
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////FREEFORM SUPERCLASS////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
-
-
-function DMAFreeFormCell(indices, scale, parentCellPos, parentCellQuat, direction, parentType){//no rigid lattice structure for cells
-    this.parentPos = parentCellPos;
-    this.parentQuaternion = parentCellQuat;
-    this.parentDirection = direction;
-    this.parentType = parentType;
-    DMACell.call(this, indices, scale);
-}
-DMAFreeFormCell.prototype = Object.create(DMACell.prototype);
-
-DMAFreeFormCell.prototype._calcPosition = function(){//todo this might not be necessary - put in lattice
-    var position = {};
-    var zScale = dmaGlobals.lattice.zScale();
-    position.x = this.parentPos.x+this.parentDirection.x*zScale/2;
-    position.y = this.parentPos.y+this.parentDirection.y*zScale/2;
-    position.z = this.parentPos.z+this.parentDirection.z*zScale/2;
-    return position;
-};
-
-DMAFreeFormCell.prototype.calcHighlighterPosition = function(face){
-    var direction = face.normal.clone();
-    direction.applyQuaternion(this.cellMesh.quaternion);
-    var position = this.getPosition();
-    position.add(direction.clone().multiplyScalar(this.zScale()/2));
-    return {index: _.clone(this.indices), direction:direction, position:position};
-};
-
-DMAFreeFormCell.prototype.toJSON = function(){
-    var json = DMACell.prototype.toJSON.call(this);
-    _.extend(json, {
-        parentPosition: this.parentPos,
-        parentOrientation: this.parentQuaternion,
-        direction: this.parentDirection,
-        parentType: this.parentType,
-        type: this.getType()
-    });
-    return json;
 };
\ No newline at end of file
diff --git a/js/fea/DmaCellOcta.js b/js/fea/DmaCellOcta.js
index 0c269cf7868279f0f01b96b53ba71eb3028f3cce..817b20e30470709a8d2624a0a6e5f05521f970ab 100644
--- a/js/fea/DmaCellOcta.js
+++ b/js/fea/DmaCellOcta.js
@@ -56,69 +56,6 @@ DMAFaceOctaCell.prototype.calcHighlighterPosition = function(face){
 };
 
 
-///////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////FREEFORM CONNECTED/////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
-
-
-function DMAFreeFormOctaCell(indices, scale, parentCellPos, parentCellQuat, direction, parentType){
-    DMAFreeFormCell.call(this, indices, scale, parentCellPos, parentCellQuat, direction, parentType);
-}
-DMAFreeFormOctaCell.prototype = Object.create(DMAFreeFormCell.prototype);
-
-DMAFreeFormOctaCell.prototype._doMeshTransformations = function(mesh){
-
-    if (!this.parentDirection) {
-        this.parentDirection = new THREE.Vector3(0,0,1);
-        this.parentQuaternion = new THREE.Quaternion();
-        this.parentPos = new THREE.Vector3(0,0,0);
-    }
-    var direction = this.parentDirection.clone();
-    var zAxis = new THREE.Vector3(0,0,1);
-    zAxis.applyQuaternion(this.parentQuaternion);
-    var quaternion = new THREE.Quaternion().setFromUnitVectors(zAxis, direction);
-    quaternion.multiply(this.parentQuaternion);
-
-    if ((this.parentType == "octa" && direction.sub(zAxis).length() < 0.1) || this.parentType == "tetra"){
-        var zRot = new THREE.Quaternion().setFromAxisAngle(this.parentDirection, Math.PI);
-        zRot.multiply(quaternion);
-        quaternion = zRot;
-    }
-
-    var eulerRot = new THREE.Euler().setFromQuaternion(quaternion);
-    mesh.rotation.set(eulerRot.x, eulerRot.y, eulerRot.z);
-};
-
-DMAFreeFormOctaCell.prototype._initParts = function(){
-    var parts  = [];
-    parts.push(new DMAOctaTroxPart(1, this));
-    return parts;
-};
-
-DMAFreeFormOctaCell.prototype.getType = function(){
-    return "octa";
-};
-
-DMAFreeFormOctaCell.prototype._getGeometry = function(){
-    return unitFaceOctaGeo;
-};
-
-DMAFreeFormOctaCell.prototype.xScale = function(scale){
-    if (!scale) scale = this.getScale();
-    return scale;
-};
-
-DMAFreeFormOctaCell.prototype.yScale = function(scale){
-    return this.xScale(scale)/2*Math.sqrt(3);
-};
-
-DMAFreeFormOctaCell.prototype.zScale = function(scale){
-    if (!scale) scale = this.getScale();
-    return scale*2/Math.sqrt(6);
-};
-
-
-
 ///////////////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////EDGE CONNECTED/////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/js/fea/DmaCellTetra.js b/js/fea/DmaCellTetra.js
index 3faa86fae78096f8fe9d6da44cd948447bc11557..6857eabee305fa32be91c88bb860220a89934ec3 100644
--- a/js/fea/DmaCellTetra.js
+++ b/js/fea/DmaCellTetra.js
@@ -46,65 +46,3 @@ function DMATetraEdgeCell(indices, scale, cellMode, partType){
 DMATetraEdgeCell.prototype = Object.create(DMATetraFaceCell.prototype);
 
 DMATetraEdgeCell.prototype._doMeshTransformations = function(){};
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////FREEFORM CONNECTED/////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
-
-
-var unitCellGeo2 = new THREE.TetrahedronGeometry(Math.sqrt(3/8));
-unitCellGeo2.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI/4));
-unitCellGeo2.applyMatrix(new THREE.Matrix4().makeRotationX((Math.PI-Math.atan(2*Math.sqrt(2)))/2));
-
-function DMAFreeFormTetraCell(indices, scale, parentCellPos, parentCellQuat, direction, parentType){
-    DMAFreeFormCell.call(this, indices, scale, parentCellPos, parentCellQuat, direction, parentType);
-}
-DMAFreeFormTetraCell.prototype = Object.create(DMAFreeFormCell.prototype);
-
-DMAFreeFormTetraCell.prototype._doMeshTransformations = function(mesh){
-    var direction = this.parentDirection.clone();
-    var zAxis = new THREE.Vector3(0,0,1);
-    zAxis.applyQuaternion(this.parentQuaternion);
-    var quaternion = new THREE.Quaternion().setFromUnitVectors(zAxis, direction);
-    quaternion.multiply(this.parentQuaternion);
-
-    if (this.parentType == "octa" && direction.sub(zAxis).length() > 0.1){//only do this if connecting to octa
-        var zRot = new THREE.Quaternion().setFromAxisAngle(this.parentDirection, Math.PI);
-        zRot.multiply(quaternion);
-        quaternion = zRot;
-    }
-
-    var eulerRot = new THREE.Euler().setFromQuaternion(quaternion);
-    mesh.rotation.set(eulerRot.x, eulerRot.y, eulerRot.z);
-};
-
-DMAFreeFormTetraCell.prototype.getType = function(){
-    return "tetra";
-};
-
-DMAFreeFormTetraCell.prototype._initParts = function(){
-    var parts  = [];
-    parts.push(new DMATetraTroxPart(1, this));
-    return parts;
-};
-
-DMAFreeFormTetraCell.prototype.xScale = function(scale){
-    if (!scale) scale = this.getScale();
-    return scale;
-};
-
-DMAFreeFormTetraCell.prototype.yScale = function(scale){
-    return this.xScale(scale)/2*Math.sqrt(3);
-};
-
-DMAFreeFormTetraCell.prototype.zScale = function(scale){
-    if (!scale) scale = this.getScale();
-    return scale*2/Math.sqrt(24);
-};
-
-DMAFreeFormTetraCell.prototype._getGeometry = function(){
-    return unitCellGeo2;
-};
-
-