made the php backend more readable

and better file handling