Fixed multiple small bugs