Fixed error handling in 16-bit functions (untested).