Work on state management, updated all older code fragments to conform
with current graphics engine