some refinement of exception handling and code style cleanup