Move static functions from .h to .c
Change size type to size_t