Simplify some code that was needlessly complex