altered input.c, only master thread reads input, cleaned up code and added comments