Various fixes for php