Added more helper functions. Other changes.