Refactoring to knockout.js

Refactor, review, pull.