Massive overhaul for thread support & thread support added