add preferences and login, fix bugs