Inlining methods/functions in core.

Inlining small methods/functions in core.
Also inlining some functions which take functions as arguments.