numerous bug fixing