fair amount of small changes and added some still unused code