Some of this code is bad and I should feel bad.