This commit moves some code from internall project.