Cleanup and new php function.