Fix JS crash, add dependencies and code for 3 – 6