Implemented DrawState stuff (not yet optimized)