Change in script arrangement and doc update

Many scattered functions in sepparate files have been joined in the same R file for convenience