Moved preview pane code to its own file, and major overhaul of code to remove some un-necessary complexity, and use more consistent terminology.