Code cleanup in scriptmgr
Added more debug information