moved code from executable to library.