Fixed various small bugs