diff --git a/src/components/costume-canvas.js b/src/components/costume-canvas.js
index ac0646756ff97c7d05e940c52f46bffc57681be5..368d52a9be70056ed9b4f6ad6df427e80289b4eb 100644
--- a/src/components/costume-canvas.js
+++ b/src/components/costume-canvas.js
@@ -25,6 +25,9 @@ class CostumeCanvas extends React.Component {
         }
     }
     draw () {
+        if (!this.refs.costumeCanvas) {
+            return;
+        }
         // Draw the costume to the rendered canvas.
         const img = this.img;
         const context = this.refs.costumeCanvas.getContext('2d');
diff --git a/src/components/library.js b/src/components/library.js
index 203c7aa5f81c237d7de2a543c380c26342a2e898..f301329cec0ee03e9a613dd766423e89a651f519 100644
--- a/src/components/library.js
+++ b/src/components/library.js
@@ -28,8 +28,8 @@ class LibraryComponent extends React.Component {
             return <LibraryItem
                 name={dataItem.name}
                 iconURL={scratchURL}
-                key={'item_' + itemId}
-                selected={this.state.selectedItem == itemId}
+                key={'item_' + id}
+                selected={this.state.selectedItem == id}
                 onSelect={this.onSelect}
                 id={id} />;
         });