public static function SetTemplate($sTemplateFilename, $sMasterpageFilename = null){
            $oThis = self::CreateInstanceIfNotExists();
            
            if(is_object($oThis->oSmarty)){
                if(!is_null($sMasterpageFilename)){
                    $sContent = $oThis->oSmarty->fetch($sTemplateFilename);
                    $oThis->oSmarty->assign('template', $sContent); 
                    $oThis->sTemplateFilename = $sMasterpageFilename;
                }
                else{
                    $oThis->sTemplateFilename = $sTemplateFilename;
                }
            }
            else{
                $sTemplate = (file_exists($sTemplateFilename)) ? file_get_contents($sTemplateFilename) : null;
                $sMasterpage = (file_exists($sMasterpageFilename)) ? file_get_contents($sMasterpageFilename) : null;

                if(!is_null($sMasterpage))
                    $oThis->sBuffer = str_replace("{\$template}", $sTemplate, $sMasterpage);
                else
                    $oThis->sBuffer = $sTemplate;

                if(Storage::Get("app.minified") && !Storage::Get("debug"))
                    $oThis->SanitizeOutput($oThis->sBuffer);

                $oThis->IncludeTemplate();
            }
        }