move code from .h to .c (where it is not pointless)