JS efficiency and cleanup