Move some functions

Oops, wrong location.