Added threading, basic verifications for inputs and small changes