SYS-fix-39a5.6: Fixed numerous bugs from previous commit