bug fixes, code optimising

* fixes AKSW/semann#15
* reduced DOM calls