fixed several buggs