Added common functions.

TODO: Move into separate file?