[Do Not Merge] Added common functions to a separate module

1) please do not merge
2) I want to rebase this on top of PR #425 and PR #426.