js code for mixed fields slightly refuctored. Ready to fix bug #20