Fixed some bugs + begin to add preferences part