Fixed PHP5.5-only function and memory leak.