added default 100ms sleep, fixed a casting issue in debug output