Started refractoring code and started working on getting a preference file to work