Cleaning code up a big