VArious bug fixes