Completely restructured formset js to make it more flexible.