Inlined some local functions