Tidied circuits code somewhat.