Changed repositioning routines so that they are fully decupled from the database