Fixes for gd and other methods, speed improvements for all methods