split script into mvc & various other minor changes