Remove loads of unnecessary code, by adding filter functions