added some debug info, fixed some syntax