changed headers and added some const correctness