Cleanup, and convert to a .php template