Moved functions

(so they don't get defined twice)