Fixed a bug in which the output may not be 16-bit aligned under some
circumstances. Also fixed text formatting and indentation in the source
code.