Add utility functions and monkey-patches