Fix php warning and clean up