initial commit from old sourcebase plus additional fixes