Refactor JavaScript decomposition. Display better error messages.