<<I call this before my pixel plotting routines in a loop
You're not using it likes this, right:
You should call it before the loops. Or even better, use a temporary buffer where you draw your "screen", wait for the retrace and then move the data from the buffer to the video memory.
for(Y=0; Y<200; Y++)
for(X=0; X<320; X++)
You say it crashes when you exit the program? Are you sure you've deallocated all dynamically allocated memory?
And for the weird characters, are you replacing the original keyboard handler without restoring it?
Hope some of this helps .