Refactor javascript behaviors and styles