Re-organized code for manageability.
Added state-machine class in preparation for PGN import.