cleaned up Main; initial support for persistence