Re-structured to make the host applications easier to write

Also added an analysis application.