cleaned up exception handling and added interactive mode.