Moved code from .h to .cpp.

Faster compilation time.
Small interface changes. Nothing important.