fixing retrieve and cleaning up some stuff