Detaching entities and ids using separate methods. Made ids sort naturally as well.