Fixed a few small bugs + cleaned code

Fixed app not starting when no data was inserted in the preferences.
Also cleaned code up further.