Remove a lot of complicated code