added load flow, firsttime flag...and many other stuff