Changed design of  backprop algorithm and implemented helper functions.