Fixed problem with being 90 degrees off in finding gradient direction. Other problems still exist