misc improvements; bug fixing