Fix compile errors and add debug print statements