fixed bug of merging headers; improved doc; comments