Improved handling of colour images and tweaked memory allocation