Added int scope setting and fixed cleanup bugs