Cleaned up some ancillary functions