fix header code duplication, code style fixes