Started to integrate code from previous work.