Refactor form class to use ob_start and ob_get_clean