inlined some functions in period.c