Performance fixes

Fixing the following performance related issues:
- freeing ```delta``` in ```compute_non_edge_forces``` to address memory leak
- use an ```xrange``` in ```_gradient_descent``` to reduce memory impact