Made config reading external function, updated encoder function. Changed everything to use config