Fix wrong limit + segment type cast