Fixed GUI exception handling and refactored Tpdohp program