Added missing headers and fixed some compile errors