Stuff from in class, plug double-buffering courtesy of THE MAN HIMSELF (AKA Fowler)