diff --git a/src/Elements/OpalBeamline.cpp b/src/Elements/OpalBeamline.cpp
index 076e433c16d1eebbc0c639e3fd1a458c69582d35..c5ece25db1bebdd4ff060e582509ba851741b274 100644
--- a/src/Elements/OpalBeamline.cpp
+++ b/src/Elements/OpalBeamline.cpp
@@ -204,10 +204,24 @@ FieldList OpalBeamline::getElementByType(ElementBase::ElementType type) {
     return elements_of_requested_type;
 }
 
+void OpalBeamline::positionElementRelative(std::shared_ptr<ElementBase> element) {
+    if (!element->isPositioned()) {
+        return;
+    }
+
+    element->releasePosition();
+    CoordinateSystemTrafo toElement = element->getCSTrafoGlobal2Local();
+    toElement *= coordTransformationTo_m;
+
+    element->setCSTrafoGlobal2Local(toElement);
+    element->fixPosition();
+}
+
 void OpalBeamline::compute3DLattice() {
     static unsigned int order = 0;
     const FieldList::iterator end = elements_m.end();
 
+
     unsigned int minOrder = order;
     {
         double endPriorPathLength = 0.0;
@@ -500,6 +514,13 @@ namespace {
         source = boost::regex_replace(source, cCommentExpr, commentFormat);
         source = boost::regex_replace(source, lineEnd, lineEndFormat, boost::match_default | boost::format_all);
 
+        // Since the positions of the elements are absolute in the laboratory coordinate system we have to make
+        // sure that the line command doesn't provide an origin and orientation. Everything after the sequence of
+        // elements can be deleted and only "LINE = (...);", the first sub-expression (denoted by '\1'), should be kept.
+        const boost::regex lineCommand("(LINE[ \t]*=[ \t]*\\([^\\)]*\\))[ \t]*,[^;]*;", boost::regex::icase);
+        const std::string firstSubExpression("\\1;");
+        source = boost::regex_replace(source, lineCommand, firstSubExpression);
+
         return source;
     }
 
@@ -615,4 +636,4 @@ void OpalBeamline::activateElements() {
         (*it).setOn(designEnergy);
         // element->goOnline(designEnergy);
     }
-}
+}
\ No newline at end of file
diff --git a/src/Elements/OpalBeamline.h b/src/Elements/OpalBeamline.h
index 49d8e75fa08ee4ef524c29b7079c2f3fc3efffa3..7f07f539407fd113ee4f60ee16146d2d1b5aef7f 100644
--- a/src/Elements/OpalBeamline.h
+++ b/src/Elements/OpalBeamline.h
@@ -83,6 +83,7 @@ public:
     void visit(const T &, BeamlineVisitor &, PartBunchBase<double, 3> *);
 
     void prepareSections();
+    void positionElementRelative(std::shared_ptr<ElementBase>);
     void compute3DLattice();
     void save3DLattice();
     void save3DInput();
@@ -109,6 +110,8 @@ void OpalBeamline::visit(const T &element, BeamlineVisitor &, PartBunchBase<doub
     double endField = 0.0;
     std::shared_ptr<T> elptr(dynamic_cast<T *>(element.clone()));
 
+    positionElementRelative(elptr);
+
     if (elptr->isElementPositionSet())
         startField = elptr->getElementPosition();
 
@@ -123,6 +126,8 @@ void OpalBeamline::visit<Source>(const Source &element, BeamlineVisitor &, PartB
     double endField = 0.0;
     std::shared_ptr<Source> elptr(dynamic_cast<Source *>(element.clone()));
 
+    positionElementRelative(elptr);
+
     if (elptr->isElementPositionSet())
         startField = elptr->getElementPosition();