Restructuring for direct deployment to google appengine;