Fixed bugs that crashed application