Move code from phtml to block. Reformat code for other files.