Switched back to code which works, about to test frame buffering.