Adds config file functionality and fixes several small bugs.