Fix javascript bugs