Maybe I'm too tired to think straight(it's almost 4 AM now) but why bother calling SetInternalResolution twice? Seems like a waste of memory/time. Just call it once at the end.. :\