This part of the code is the worst offender.  I'll try to go easy on the ternary operator in the future.