 			_penToolMenuItem.caption = ENABLE_PEN;
 			_removeDrawingsMenuItem.enabled = false;
 			//If session state is imported need to detect if there already is drawings.
-			if( ( getLinkableContainer(e.mouseTarget) as ILinkableContainer).getLinkableChildren().getObject( PEN_OBJECT_NAME ) )
-			{
-				var penObject:ILinkableObject = ( getLinkableContainer(e.mouseTarget) as ILinkableContainer).getLinkableChildren().getObject( PEN_OBJECT_NAME );
-				if( ( penObject as PenMouse ).penEnabled.value == true )
-					_penToolMenuItem.caption = DISABLE_PEN;
-				else
-					_penToolMenuItem.caption = ENABLE_PEN;
-				_removeDrawingsMenuItem.enabled = true;
-			}
+			//Check if LinkableContainer is null.
+			if( ( getLinkableContainer(e.mouseTarget) as ILinkableContainer) )
+				if( ( getLinkableContainer(e.mouseTarget) as ILinkableContainer).getLinkableChildren().getObject( PEN_OBJECT_NAME ) )
+				{
+					var penObject:ILinkableObject = ( getLinkableContainer(e.mouseTarget) as ILinkableContainer).getLinkableChildren().getObject( PEN_OBJECT_NAME );
+					if( ( penObject as PenMouse ).penEnabled.value == true )
+					{
+						_penToolMenuItem.caption = DISABLE_PEN;
+						( penObject as PenMouse).editMode = true;
+					}
+					else
+					{
+						_penToolMenuItem.caption = ENABLE_PEN;
+					}
+					_removeDrawingsMenuItem.enabled = true;
+				}
 		}
 		
 		/**

			{
				// disable pen
				penTool.editMode = false;
				
				_penToolMenuItem.caption = ENABLE_PEN;
			}

			if(!destination.hasOwnProperty("contextMenu") )
				return false;
			
			// Add a listener to this destination context menu for when it is opened
			var contextMenu:ContextMenu = destination["contextMenu"] as ContextMenu;
			contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, handleContextMenuOpened);
