More utility functions

@flacjacket Please review this.