#372: Added cleanup and fixes
#372: fixes