prepare release and constify
fix possible memory leak (already partially fixed in php master)