add cleanup, fix shadowing.