Corrected various small bugs