Random functions merged with all the refactor