Initial commit from BW
Merged two versions