Rewrite backprop algorithm

Backprop appears to be working now, but I've only tested it on single layer networks.