Header changes and code cleaning