Make 2.4 compatible

2.4 has a few differences which are incompatible with the current code.