Fixed various cleanup issues

Change-Id: Ie03440f350fd2e4add1c6f9f29d5e85e43762454