Made some perfomance improvements