Improved thread safety
Something doesn't work, not sure why
Really old, i have no idea what i did