Lots of assorted logic here