bug fixes, documented js, improved code