Fixed errors in address generation