fixed memory leaks and added parameter to choose disk size