Fixed S21 issue and minor bugs