JS fixes, bugfixes and preparing for new features