Inlining methods/functions in core.

Also inlining some functions which take functions as arguments.
Merge pull request #4467 from gifnksm/inlining-core

Inlining methods/functions in core.