Introduce some utility functions

ref #255