more fixes

fixed 'headers already sent' bug