move function definitions from header to source file

I moved some function implementations from header to source file. This is needed in case you want to include the header in multiple files.