Adding missing headers
Fixing compiler errors and definitions