added EM learning capability to rebuild_net function. Also rearranged the helper functions driving directly the Netical library functions so they are alphabetical