JS - Various bug fixes