Replace main code block with a simple singleton.