Fixed infinite loop if resolution was big enough (broke in LONG to WORD conversion)