Added php upstream
Small optimizations and movearounds