fixed some bugs and new debug support