fixed memory leak in feat.c and speed improvements.