Fix JS errors and link errors