fixing some memory bugs, rewrote neighbor features