Move cleanup to its own function
Remove unused IsBase