Added config file and cleaned up the code a bit