bug fixes and 4.x compat.