A few compatibility/bug fixes