initial cleanup

Just walked through the PHP to get a feel for everything first. Fuxed with the formatting and added translation functions where missing... simple stuff like that. More to come.