Fixed bug in deck.js
Finished refactoring