resolving headers, replacing rand calls