fix includes and some bad function calls