Put "<div>" around hidden elements put out by the formtemplate tag when a customtemplate layout rather than a style template is used and that custom templatelayout doesn't put out the hidden elements manually.
Fix default mime type! text/plain for unknown extensions is a very badidea. Treating unknown files, many of the binary as text can only leadto suffering.