Started cleaning code up