some restructuring and changes to fw.dom
also added loadTemplate method