Free memory associated with algorithms list
Fix memory leak in static_buffer

The static buffers for the other threads were being cleaned up
automatically by pthread_key_delete, but the current thread's buffer was
always being leaked. This frees it first.