Refactored code, fixed race condition and switched to namedtuples