Added argument for background texture
comments and general code cleanup