Hacked code to get it working on SDCC 3