updated to latest implementation and added some missing files.