Adding some missing variable declarations and encapsulating them properly
Adding the ability to overlay an image
Taking inspiration from examples on php.net to allow alpha layer overlay