Fixing various small bugs