Methods. Participants will undergo 22 weeks of daily methadone or buprenorphine/naloxone (henceforth buprenorphine ) maintenance and will be offered at least 8 weeks of methadone or buprenorphine taper (weeks 23-30). To track drug use, stress, and geographical location (a measure of environmental risk), each participant will carry a PDA and a GPS unit for 16 of the first 18 weeks. Event-triggered entries will be initiated by participants (1) each time that they use a drug and (2) each time they feel overwhelmed, anxious, or stressed more than usual. Participants will also make 3 random-signal-triggered recordings per day and one brief end of day recording. We will compare EMA results with more traditional assessments of drug use and stress: (1) urine will be collected three times weekly during weeks 1-22 and once weekly during the optional methadone or buprenorphine taper (weeks 23-30), (2) retrospective self-report questionnaires on drug use and stress will be given regularly, and (3) laboratory session examining responsiveness to a standardized stressor will occur during the 4th 6th week. Blood draws and anthropometric measurements to assess allostatic load (a physiological marker of long-term cumulative stress) and blood samples will be obtained for genetic analysis during the 2nd 4th week. After week 12, we will also assess the impact of opioid agonist treatment on the hypothalamic-pituitary-adrenal (HPA) axis which is involved in modulating stress. After 18 weeks of opioid agonist maintenance, participants will begin an additional 4 weeks of maintenance, during which they will not carry the PDA and GPS unit unless they are participating in a secondary study that includes those measures. At the end of 22 weeks, participants will have the choice of transferring to a community clinic or undergoing an eight-week taper at the Archway clinic. Secondary studies: Up to 70 participants will be asked to wear the Daysimeter and an Actigraph activity-monitor wristwatch for 18 days (two 72-hour intervals repeated three times) and the Dimesimeter daily (24 hours/day) for 16 weeks. Up to 80 participants will be asked to wear the AutoSense for four 1-week periods, including during laboratory sessions. Up to 40 participants will be enrolled in the mHIVRR evaluation program for 4 weeks during the Maintenance Phase (completed October 2013). Up to 100 participants will be asked to wear a SleepProfiler during 7 nights to assess sleep architecture.