Fixed bugs that caused crash on start.