Added version independence, not used atm. Made thread safe