Remove a lot of redundant code