Adding unknown command handling, refactoring JS