lots more fixes and testing