merging carl's and scotts branches 

cleaning up code