Fixes for JS logic