vitaly's bugs (lots of) fix