Other agency errors included an unchecked software bug that led to Terrorism Act detentions