Added logging; cleaned up exceptions