Fixing some exception bugs