diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py
index 2cde6bc272ff8d44b0b8a02b7015d54f7e964884..ce05ce02ccaec6ca5a8add3adef24fdcead02924 100644
--- a/flatland/envs/rail_env.py
+++ b/flatland/envs/rail_env.py
@@ -532,7 +532,10 @@ class RailEnv(Environment):
         
         self.agents_position.append(tuple(rcPos))  # ensure it's a tuple not a list
         self.agents_handles.append(max(self.agents_handles + [-1]) + 1)  # max(handles) + 1, starting at 0
-        self.agents_direction.append(0)
+
+        if iDir is None:
+            iDir = self.pick_agent_direction(rcPos, rcTarget)
+        self.agents_direction.append(iDir)
         self.agents_target.append(rcPos)  # set the target to the origin initially
         self.number_of_agents += 1
         self.check_agent_lists()
diff --git a/flatland/utils/editor.py b/flatland/utils/editor.py
index d71b05e526b6e4b19a686d6a11899629aab00cb6..88b6d7a78ee64819b1f774205900917c95adea7e 100644
--- a/flatland/utils/editor.py
+++ b/flatland/utils/editor.py
@@ -79,7 +79,7 @@ class JupEditor(object):
         rcCell = ((array([y, x]) - self.yxBase) / self.nPixCell).astype(int)
 
         if self.drawMode == "Origin":
-            self.iAgent = self.env.add_agent(rcCell, rcCell, 0)
+            self.iAgent = self.env.add_agent(rcCell, rcCell, None)
             self.drawMode = "Destination"
             self.player = None  # will need to start a new player