Refractor codes. Fix bugs. Remove call to Activate.