Thread sleep and some other small issues