Fixed divide by zero bug when rescaling