Added waitUntilUsed, tests and debug()