diff --git a/plug-ins/twain/tw_func.c b/plug-ins/twain/tw_func.c
index 671ab47..8192048 100644
--- a/plug-ins/twain/tw_func.c
+++ b/plug-ins/twain/tw_func.c
@@ -61,7 +61,7 @@
 
 #include "config.h"
 
-#include <glib.h>		/* Needed when compiling with gcc */
+#include <glib.h>   /* Needed when compiling with gcc */
 
 #include "tw_func.h"
 #include "tw_util.h"
@@ -71,7 +71,8 @@
  * Twain error code to string mappings
  */
 static int twainErrorCount = 0;
-static char *twainErrors[] = {
+static char *twainErrors[] =
+{
   "No error",
   "Failure due to unknown causes",
   "Not enough memory to perform operation",
@@ -130,7 +131,7 @@ float FIX32ToFloat(TW_FIX32 fix32)
  * with the specified error code.
  */
 char *
-twainError(int errorCode)
+twainError (int errorCode)
 {
   /* Check whether we've counted */
   if (twainErrorCount == 0)
@@ -149,7 +150,7 @@ twainError(int errorCode)
  * Return the current TWAIN error message.
  */
 char *
-currentTwainError(pTW_SESSION twSession)
+currentTwainError (pTW_SESSION twSession)
 {
   TW_STATUS twStatus;
 
@@ -159,47 +160,50 @@ currentTwainError(pTW_SESSION twSession)
 			    (TW_MEMREF) &twStatus);
 
   /* Return the mapped error code */
-  return twainError(twStatus.ConditionCode);
+  return twainError (twStatus.ConditionCode);
 }
 
-
 /*
  * getImage
  *
  * This is a "high-level" function that can be called in order
  * to take all of the steps necessary to kick off an image-transfer
- * from a user-specified TWAIN datasource.  The data will be passed
+ * from a user-specified TWAIN datasource. The data will be passed
  * back to the callback function specified in the session structure.
  */
 int
-getImage(pTW_SESSION twSession)
+getImage (pTW_SESSION twSession)
 {
   /* Do some sanity checking first and bail
    * if necessary.
    */
 
-  if (!twainIsAvailable()) {
+  if (!twainIsAvailable ())
+  {
     LogMessage("TWAIN is not available for image capture\n");
     return FALSE;
   }
 
   /* One step at a time */
-  if (!openDSM(twSession)) {
+  if (!openDSM (twSession))
+  {
     LogMessage("Unable to open data source manager\n");
     return FALSE;
   }
 
-  if (!selectDS(twSession)) {
+  if (!selectDS (twSession))
+  {
     LogMessage("Data source not selected\n");
     return FALSE;
   }
 
-  if (!openDS(twSession)) {
+  if (!openDS (twSession))
+  {
     LogMessage("Unable to open datasource\n");
     return FALSE;
   }
 
-  requestImageAcquire(twSession, TRUE);
+  requestImageAcquire (twSession, TRUE);
 
   return TRUE;
 }
@@ -210,7 +214,7 @@ getImage(pTW_SESSION twSession)
  * Open the data source manager
  */
 int
-openDSM(pTW_SESSION twSession)
+openDSM (pTW_SESSION twSession)
 {
   /* Make sure that we aren't already open */
   if (DSM_IS_OPEN(twSession))
@@ -218,11 +222,12 @@ openDSM(pTW_SESSION twSession)
 
   /* Open the data source manager */
   twSession->twRC = callDSM(APP_IDENTITY(twSession), NULL,
-			    DG_CONTROL, DAT_PARENT, MSG_OPENDSM,
-			    (TW_MEMREF) &(twSession->hwnd));
+      DG_CONTROL, DAT_PARENT, MSG_OPENDSM,
+      (TW_MEMREF) &(twSession->hwnd));
 
   /* Check the return code */
-  switch (twSession->twRC) {
+  switch (twSession->twRC)
+  {
     case TWRC_SUCCESS:
       /* We are now at state 3 */
       twSession->twainState = 3;
@@ -245,37 +250,39 @@ openDSM(pTW_SESSION twSession)
  * interface.
  */
 int
-selectDS(pTW_SESSION twSession)
+selectDS (pTW_SESSION twSession)
 {
   /* The datasource manager must be open */
-  if (DSM_IS_CLOSED(twSession)) {
+  if (DSM_IS_CLOSED(twSession))
+  {
     LogMessage("Can't select data source with closed source manager\n");
     return FALSE;
   }
 
   /* Ask TWAIN to present the source select dialog */
   twSession->twRC = callDSM(APP_IDENTITY(twSession), NULL,
-			    DG_CONTROL, DAT_IDENTITY, MSG_USERSELECT,
-			    (TW_MEMREF) DS_IDENTITY(twSession));
+      DG_CONTROL, DAT_IDENTITY, MSG_USERSELECT,
+      (TW_MEMREF) DS_IDENTITY(twSession));
 
   /* Check the return to determine what the user decided
    * to do.
    */
-  switch (twSession->twRC) {
-  case TWRC_SUCCESS:
-    LogMessage("Data source %s selected\n", DS_IDENTITY(twSession)->ProductName);
-    return TRUE;
-    break;
+  switch (twSession->twRC)
+  {
+    case TWRC_SUCCESS:
+      LogMessage ("Data source %s selected\n", DS_IDENTITY(twSession)->ProductName);
+      return TRUE;
+      break;
 
-  case TWRC_CANCEL:
-    LogMessage("User cancelled TWAIN source selection\n");
-    break;
+    case TWRC_CANCEL:
+      LogMessage ("User cancelled TWAIN source selection\n");
+      break;
 
-  case TWRC_FAILURE:
-  default:
-    LogMessage("Error \"%s\" during TWAIN source selection\n",
+    case TWRC_FAILURE:
+    default:
+      LogMessage ("Error \"%s\" during TWAIN source selection\n",
 	       currentTwainError(twSession));
-    break;
+      break;
   }
 
   return FALSE;
@@ -310,18 +317,20 @@ selectDefaultDS(pTW_SESSION twSession)
  * Open a data source using the TWAIN user interface.
  */
 int
-openDS(pTW_SESSION twSession)
+openDS (pTW_SESSION twSession)
 {
   TW_IDENTITY *dsIdentity;
 
   /* The datasource manager must be open */
-  if (DSM_IS_CLOSED(twSession)) {
+  if (DSM_IS_CLOSED(twSession))
+  {
     LogMessage("openDS: Cannot open data source... manager closed\n");
     return FALSE;
   }
 
   /* Is the data source already open? */
-  if (DS_IS_OPEN(twSession)) {
+  if (DS_IS_OPEN(twSession))
+  {
     LogMessage("openDS: Data source already open\n");
     return TRUE;
   }
@@ -335,24 +344,25 @@ openDS(pTW_SESSION twSession)
   /* Check the return to determine what the user decided
    * to do.
 	 */
-  switch (twSession->twRC) {
-  case TWRC_SUCCESS:
-    /* We are now in TWAIN state 4 */
-    twSession->twainState = 4;
-    LogMessage("Data source %s opened\n", DS_IDENTITY(twSession)->ProductName);
-    LogMessage("\tVersion.MajorNum = %d\n", dsIdentity->Version.MajorNum);
-    LogMessage("\tVersion.MinorNum = %d\n", dsIdentity->Version.MinorNum);
-    LogMessage("\tVersion.Info = %s\n", dsIdentity->Version.Info);
-    LogMessage("\tProtocolMajor = %d\n", dsIdentity->ProtocolMajor);
-    LogMessage("\tProtocolMinor = %d\n", dsIdentity->ProtocolMinor);
-    LogMessage("\tManufacturer = %s\n", dsIdentity->Manufacturer);
-    LogMessage("\tProductFamily = %s\n", dsIdentity->ProductFamily);
-    return TRUE;
-    break;
+  switch (twSession->twRC)
+  {
+    case TWRC_SUCCESS:
+      /* We are now in TWAIN state 4 */
+      twSession->twainState = 4;
+      LogMessage("Data source %s opened\n", DS_IDENTITY(twSession)->ProductName);
+      LogMessage("\tVersion.MajorNum = %d\n", dsIdentity->Version.MajorNum);
+      LogMessage("\tVersion.MinorNum = %d\n", dsIdentity->Version.MinorNum);
+      LogMessage("\tVersion.Info = %s\n", dsIdentity->Version.Info);
+      LogMessage("\tProtocolMajor = %d\n", dsIdentity->ProtocolMajor);
+      LogMessage("\tProtocolMinor = %d\n", dsIdentity->ProtocolMinor);
+      LogMessage("\tManufacturer = %s\n", dsIdentity->Manufacturer);
+      LogMessage("\tProductFamily = %s\n", dsIdentity->ProductFamily);
+      return TRUE;
+      break;
 
-  default:
-    LogMessage("Error \"%s\" opening data source\n", currentTwainError(twSession));
-    break;
+    default:
+      LogMessage("Error \"%s\" opening data source\n", currentTwainError(twSession));
+      break;
   }
 
   return FALSE;
@@ -362,7 +372,7 @@ openDS(pTW_SESSION twSession)
  * setBufferedXfer
  */
 static int
-setBufferedXfer(pTW_SESSION twSession)
+setBufferedXfer (pTW_SESSION twSession)
 {
   TW_CAPABILITY bufXfer;
   pTW_ONEVALUE pvalOneValue;
@@ -374,12 +384,12 @@ setBufferedXfer(pTW_SESSION twSession)
   /* Create the capability information */
   bufXfer.Cap = ICAP_XFERMECH;
   bufXfer.ConType = TWON_ONEVALUE;
-  bufXfer.hContainer = twainAllocHandle(sizeof(TW_ONEVALUE));
+  bufXfer.hContainer = twainAllocHandle (sizeof(TW_ONEVALUE));
 
-  pvalOneValue = (pTW_ONEVALUE) twainLockHandle(bufXfer.hContainer);
+  pvalOneValue = (pTW_ONEVALUE) twainLockHandle (bufXfer.hContainer);
   pvalOneValue->ItemType = TWTY_UINT16;
   pvalOneValue->Item = TWSX_MEMORY;
-  twainUnlockHandle(bufXfer.hContainer);
+  twainUnlockHandle (bufXfer.hContainer);
 
   /* Make the call to the source manager */
   twSession->twRC = callDSM(APP_IDENTITY(twSession), DS_IDENTITY(twSession),
@@ -387,7 +397,7 @@ setBufferedXfer(pTW_SESSION twSession)
 			    (TW_MEMREF) &bufXfer);
 
   /* Free the container */
-  twainFreeHandle(bufXfer.hContainer);
+  twainFreeHandle (bufXfer.hContainer);
 
   /* Let the caller know what happened */
   return (twSession->twRC==TWRC_SUCCESS);
@@ -401,10 +411,11 @@ setBufferedXfer(pTW_SESSION twSession)
  * an image to actually be transferred.
  */
 int
-requestImageAcquire(pTW_SESSION twSession, gboolean showUI)
+requestImageAcquire (pTW_SESSION twSession, gboolean showUI)
 {
   /* Make sure in the correct state */
-  if (DS_IS_CLOSED(twSession)) {
+  if (DS_IS_CLOSED(twSession))
+  {
     LogMessage("Can't acquire image with closed datasource\n");
     return FALSE;
   }
@@ -412,7 +423,8 @@ requestImageAcquire(pTW_SESSION twSession, gboolean showUI)
   twainSetupCallback(twSession);
 
   /* Set the transfer mode */
-  if (setBufferedXfer(twSession)) {
+  if (setBufferedXfer (twSession))
+  {
     TW_USERINTERFACE ui;
 
     /* Set the UI information */
@@ -426,16 +438,21 @@ requestImageAcquire(pTW_SESSION twSession, gboolean showUI)
 			      DG_CONTROL, DAT_USERINTERFACE, MSG_ENABLEDS,
 			      (TW_MEMREF) &ui);
 
-    if (twSession->twRC == TWRC_SUCCESS) {
+    if (twSession->twRC == TWRC_SUCCESS)
+    {
       /* We are now at a new twain state */
       twSession->twainState = 5;
 
       return TRUE;
-    } else {
+    }
+	else
+    {
       LogMessage("Error during data source enable\n");
       return FALSE;
     }
-  } else {
+  }
+  else
+  {
     LogMessage("Unable to set buffered transfer mode: %s\n",
 	       currentTwainError(twSession));
     return FALSE;
@@ -451,12 +468,12 @@ int
 disableDS(pTW_SESSION twSession)
 {
     TW_USERINTERFACE ui;
-
-	/* Verify the datasource is enabled */
-	if (DS_IS_DISABLED(twSession)) {
-		LogMessage("disableDS: Data source not enabled\n");
-		return TRUE;
-	}
+  /* Verify the datasource is enabled */
+  if (DS_IS_DISABLED(twSession))
+  {
+    LogMessage("disableDS: Data source not enabled\n");
+    return TRUE;
+  }
 
     /* Set the UI information */
     ui.ShowUI = TRUE;
@@ -468,12 +485,15 @@ disableDS(pTW_SESSION twSession)
 			      DG_CONTROL, DAT_USERINTERFACE, MSG_DISABLEDS,
 			      (TW_MEMREF) &ui);
 
-    if (twSession->twRC == TWRC_SUCCESS) {
+    if (twSession->twRC == TWRC_SUCCESS)
+    {
       /* We are now at a new twain state */
       twSession->twainState = 4;
 
       return TRUE;
-    } else {
+    }
+    else
+    {
       LogMessage("Error during data source disable\n");
       return FALSE;
     }
@@ -486,10 +506,11 @@ disableDS(pTW_SESSION twSession)
  * specified session.
  */
 int
-closeDS(pTW_SESSION twSession)
+closeDS (pTW_SESSION twSession)
 {
   /* Can't close a closed data source */
-  if (DS_IS_CLOSED(twSession)) {
+  if (DS_IS_CLOSED(twSession))
+  {
     LogMessage("closeDS: Data source already closed\n");
     return TRUE;
   }
@@ -502,17 +523,18 @@ closeDS(pTW_SESSION twSession)
   /* Check the return to determine what the user decided
    * to do.
 	 */
-  switch (twSession->twRC) {
-  case TWRC_SUCCESS:
-    /* We are now in TWAIN state 3 */
-    twSession->twainState = 3;
-    LogMessage("Data source %s closed\n", DS_IDENTITY(twSession)->ProductName);
-    return TRUE;
-    break;
+  switch (twSession->twRC)
+  {
+    case TWRC_SUCCESS:
+      /* We are now in TWAIN state 3 */
+      twSession->twainState = 3;
+      LogMessage("Data source %s closed\n", DS_IDENTITY(twSession)->ProductName);
+      return TRUE;
+      break;
 
-  default:
-    LogMessage("Error \"%s\" closing data source\n", currentTwainError(twSession));
-    break;
+    default:
+      LogMessage("Error \"%s\" closing data source\n", currentTwainError(twSession));
+      break;
   }
 
   return FALSE;
@@ -524,12 +546,15 @@ closeDS(pTW_SESSION twSession)
  * Close the data source manager
  */
 int
-closeDSM(pTW_SESSION twSession)
+closeDSM (pTW_SESSION twSession)
 {
-  if (DSM_IS_CLOSED(twSession)) {
+  if (DSM_IS_CLOSED(twSession))
+  {
     LogMessage("closeDSM: Source Manager not open\n");
     return FALSE;
-  } else {
+  }
+  else
+  {
     if (DS_IS_OPEN(twSession)) {
       LogMessage("closeDSM: Can't close source manager with open source\n");
       return FALSE;
@@ -542,9 +567,8 @@ closeDSM(pTW_SESSION twSession)
 				LogMessage("CloseDSM failure -- %s\n", currentTwainError(twSession));
       }
       else {
-
-				/* We are now in state 2 */
-				twSession->twainState = 2;
+        /* We are now in state 2 */
+        twSession->twainState = 2;
       }
     }
   }
@@ -560,10 +584,10 @@ closeDSM(pTW_SESSION twSession)
  * Begin an image transfer.
  */
 static int
-beginImageTransfer(pTW_SESSION twSession, pTW_IMAGEINFO imageInfo)
+beginImageTransfer (pTW_SESSION twSession, pTW_IMAGEINFO imageInfo)
 {
   /* Clear our structures */
-  memset(imageInfo, 0, sizeof(TW_IMAGEINFO));
+  memset (imageInfo, 0, sizeof (TW_IMAGEINFO));
 
   /* Query the image information */
   twSession->twRC = callDSM(
@@ -572,7 +596,8 @@ beginImageTransfer(pTW_SESSION twSession, pTW_IMAGEINFO imageInfo)
 			    (TW_MEMREF) imageInfo);
 
   /* Check the return code */
-  if (twSession->twRC != TWRC_SUCCESS) {
+  if (twSession->twRC != TWRC_SUCCESS)
+  {
     LogMessage("Get Image Info failure - %s\n", currentTwainError(twSession));
 
     return FALSE;
@@ -580,7 +605,7 @@ beginImageTransfer(pTW_SESSION twSession, pTW_IMAGEINFO imageInfo)
 
   /* Call the begin transfer callback if registered */
   if (twSession->transferFunctions->txfrBeginCb)
-    if (!(*twSession->transferFunctions->txfrBeginCb)(imageInfo, twSession->clientData))
+    if (!(*twSession->transferFunctions->txfrBeginCb) (imageInfo, twSession->clientData))
       return FALSE;
 
   /* We should continue */
@@ -596,15 +621,15 @@ beginImageTransfer(pTW_SESSION twSession, pTW_IMAGEINFO imageInfo)
  * from State 6 to 7.  Return the reason for exiting the transfer.
  */
 static void
-transferImage(pTW_SESSION twSession, pTW_IMAGEINFO imageInfo)
+transferImage (pTW_SESSION twSession, pTW_IMAGEINFO imageInfo)
 {
   TW_SETUPMEMXFER setupMemXfer;
   TW_IMAGEMEMXFER imageMemXfer;
   char *buffer;
 
   /* Clear our structures */
-  memset(&setupMemXfer, 0, sizeof(TW_SETUPMEMXFER));
-  memset(&imageMemXfer, 0, sizeof(TW_IMAGEMEMXFER));
+  memset (&setupMemXfer, 0, sizeof (TW_SETUPMEMXFER));
+  memset (&imageMemXfer, 0, sizeof (TW_IMAGEMEMXFER));
 
   /* Find out how the source would like to transfer... */
   twSession->twRC = callDSM(APP_IDENTITY(twSession), DS_IDENTITY(twSession),
@@ -618,7 +643,8 @@ transferImage(pTW_SESSION twSession, pTW_IMAGEINFO imageInfo)
   imageMemXfer.Memory.TheMem = (TW_MEMREF) buffer;
 
   /* Get the data */
-  do {
+  do
+  {
     /* Setup for the memory transfer */
     imageMemXfer.Compression = TWON_DONTCARE16;
     imageMemXfer.BytesPerRow = TWON_DONTCARE32;
@@ -634,15 +660,17 @@ transferImage(pTW_SESSION twSession, pTW_IMAGEINFO imageInfo)
 			      (TW_MEMREF) &imageMemXfer);
 
     if ((twSession->twRC == TWRC_SUCCESS) ||
-	(twSession->twRC == TWRC_XFERDONE)) {
+        (twSession->twRC == TWRC_XFERDONE))
+    {
       /* Call the callback function */
       if (!(*twSession->transferFunctions->txfrDataCb) (
 							imageInfo,
 							&imageMemXfer,
-							twSession->clientData)) {
-	/* Callback function requested to cancel */
-	twSession->twRC = TWRC_CANCEL;
-	break;
+							twSession->clientData))
+      {
+        /* Callback function requested to cancel */
+        twSession->twRC = TWRC_CANCEL;
+        break;
       }
     }
   } while (twSession->twRC == TWRC_SUCCESS);
@@ -658,7 +686,7 @@ transferImage(pTW_SESSION twSession, pTW_IMAGEINFO imageInfo)
  * Return the count of pending transfers.
  */
 static int
-endPendingTransfer(pTW_SESSION twSession)
+endPendingTransfer (pTW_SESSION twSession)
 {
   TW_PENDINGXFERS pendingXfers;
 
@@ -678,7 +706,7 @@ endPendingTransfer(pTW_SESSION twSession)
  * Cancel all pending image transfers.
  */
 void
-cancelPendingTransfers(pTW_SESSION twSession)
+cancelPendingTransfers (pTW_SESSION twSession)
 {
   TW_PENDINGXFERS pendingXfers;
 
@@ -694,7 +722,7 @@ cancelPendingTransfers(pTW_SESSION twSession)
  * of pending images.
  */
 static int
-endImageTransfer(pTW_SESSION twSession, int *pendingCount)
+endImageTransfer (pTW_SESSION twSession, int *pendingCount)
 {
   gboolean continueTransfers;
   int exitCode = twSession->twRC;
@@ -702,17 +730,18 @@ endImageTransfer(pTW_SESSION twSession, int *pendingCount)
   /* Have now exited the transfer for some reason... Figure out
    * why and what to do about it
    */
-  switch (twSession->twRC) {
-  case TWRC_XFERDONE:
-  case TWRC_CANCEL:
+  switch (twSession->twRC)
+  {
+    case TWRC_XFERDONE:
+    case TWRC_CANCEL:
     LogMessage("Xfer done received\n");
-    *pendingCount = endPendingTransfer(twSession);
-    break;
+      *pendingCount = endPendingTransfer(twSession);
+      break;
 
-  case TWRC_FAILURE:
-    LogMessage("Failure received\n");
-    *pendingCount = endPendingTransfer(twSession);
-    break;
+    case TWRC_FAILURE:
+      LogMessage("Failure received\n");
+      *pendingCount = endPendingTransfer(twSession);
+      break;
   }
 
   /* Call the end transfer callback */
@@ -732,7 +761,7 @@ endImageTransfer(pTW_SESSION twSession, int *pendingCount)
  * datasource.
  */
 static void
-transferImages(pTW_SESSION twSession)
+transferImages (pTW_SESSION twSession)
 {
   TW_IMAGEINFO imageInfo;
   int pendingCount;
@@ -740,7 +769,8 @@ transferImages(pTW_SESSION twSession)
   /* Check the image transfer callback function
    * before even attempting to do the transfer
    */
-  if (!twSession->transferFunctions || !twSession->transferFunctions->txfrDataCb) {
+  if (!twSession->transferFunctions || !twSession->transferFunctions->txfrDataCb)
+  {
     LogMessage("Attempting image transfer without callback function\n");
     return;
   }
@@ -753,18 +783,19 @@ transferImages(pTW_SESSION twSession)
     (*twSession->transferFunctions->preTxfrCb)(twSession->clientData);
 
   /* Loop through the available images */
-  do {
+  do
+  {
     /* Move to the new state */
     twSession->twainState = 6;
 
     /* Begin the image transfer */
-    if (!beginImageTransfer(twSession, &imageInfo))
+    if (!beginImageTransfer (twSession, &imageInfo))
       continue;
 
     /* Call the image transfer function */
     transferImage(twSession, &imageInfo);
 
-  } while (endImageTransfer(twSession, &pendingCount));
+  } while (endImageTransfer (twSession, &pendingCount));
 
   /*
    * Inform our application that we are done
@@ -776,30 +807,31 @@ transferImages(pTW_SESSION twSession)
 }
 
 void
-processTwainMessage(TW_UINT16 message, pTW_SESSION twSession)
+processTwainMessage (TW_UINT16 message, pTW_SESSION twSession)
 {
-  switch (message) {
-  case MSG_XFERREADY:
-    LogMessage("Source says that data is ready\n");
-    transferImages(twSession);
-    break;
-
-  case MSG_CLOSEDSREQ:
-    /* Disable the datasource, Close the Data source
-     * and close the data source manager
+  switch (message)
+  {
+    case MSG_XFERREADY:
+      LogMessage("Source says that data is ready\n");
+      transferImages (twSession);
+      break;
+
+    case MSG_CLOSEDSREQ:
+      /* Disable the datasource, Close the Data source
+       * and close the data source manager
+       */
+      LogMessage("CloseDSReq\n");
+      disableDS (twSession);
+      closeDS (twSession);
+      closeDSM (twSession);
+      break;
+
+    /* No message from the Source to the App break;
+     * possible new message
      */
-    LogMessage("CloseDSReq\n");
-    disableDS(twSession);
-    closeDS(twSession);
-    closeDSM(twSession);
-    break;
-
-  /* No message from the Source to the App break;
-   * possible new message
-   */
-  case MSG_NULL:
-  default:
-    break;
+    case MSG_NULL:
+    default:
+      break;
   }
 }
 
@@ -813,7 +845,8 @@ processTwainMessage(TW_UINT16 message, pTW_SESSION twSession)
  * Create a new TWAIN session.
  */
 pTW_SESSION
-newSession(pTW_IDENTITY appIdentity) {
+newSession (pTW_IDENTITY appIdentity)
+{
   /* Create the structure */
   pTW_SESSION session = g_new (TW_SESSION, 1);
 
@@ -826,7 +859,7 @@ newSession(pTW_IDENTITY appIdentity) {
   session->dsIdentity->ProductName[0] = '\0';
   session->transferFunctions = NULL;
 
-  if (twainIsAvailable())
+  if (twainIsAvailable ())
     session->twainState = 2;
   else
     session->twainState = 0;
diff --git a/plug-ins/twain/tw_func.h b/plug-ins/twain/tw_func.h
index da9d377..fb4a9fb 100644
--- a/plug-ins/twain/tw_func.h
+++ b/plug-ins/twain/tw_func.h
@@ -207,31 +207,31 @@ typedef struct _TWAIN_SESSION {
 #define DS_IS_DISABLED(tw_session) (tw_session->twainState < 5)
 
 /* Function declarations */
-char *twainError(int);
-char *currentTwainError(pTW_SESSION);
-int getImage(pTW_SESSION);
-int loadTwainLibrary(pTW_SESSION);
+char *          twainError (int);
+char *          currentTwainError (pTW_SESSION);
+int             getImage (pTW_SESSION);
+int             loadTwainLibrary (pTW_SESSION);
 int unloadTwainLibrary(pTW_SESSION twSession);
-int openDSM(pTW_SESSION);
-int selectDS(pTW_SESSION);
-int selectDefaultDS(pTW_SESSION);
-int openDS(pTW_SESSION);
-int requestImageAcquire(pTW_SESSION, gboolean);
-int disableDS(pTW_SESSION);
-int closeDS(pTW_SESSION);
-int closeDSM(pTW_SESSION);
-void cancelPendingTransfers(pTW_SESSION);
+int             openDSM (pTW_SESSION);
+int             selectDS (pTW_SESSION);
+int             selectDefaultDS (pTW_SESSION);
+int             openDS (pTW_SESSION);
+int             requestImageAcquire (pTW_SESSION, gboolean);
+int             disableDS (pTW_SESSION);
+int             closeDS (pTW_SESSION);
+int             closeDSM (pTW_SESSION);
+void            cancelPendingTransfers (pTW_SESSION);
 int scanImage (void);
 
 TW_FIX32 FloatToFIX32(float);
-float FIX32ToFloat(TW_FIX32);
+float           FIX32ToFloat(TW_FIX32);
 
-void processTwainMessage(TW_UINT16 message, pTW_SESSION twSession);
+void            processTwainMessage (TW_UINT16 message, pTW_SESSION twSession);
 
-pTW_SESSION newSession(pTW_IDENTITY);
-void registerWindowHandle(pTW_SESSION, TW_HANDLE);
-void registerTransferCallbacks(pTW_SESSION, pTXFR_CB_FUNCS, void *);
-void setClientData(pTW_SESSION session, void *clientData);
+pTW_SESSION     newSession (pTW_IDENTITY);
+void            registerWindowHandle(pTW_SESSION, TW_HANDLE);
+void            registerTransferCallbacks(pTW_SESSION, pTXFR_CB_FUNCS, void *);
+void            setClientData(pTW_SESSION session, void *clientData);
 pTW_SESSION initializeTwain(void);
 
 void LogLastWinError(void);
diff --git a/plug-ins/twain/tw_local.h b/plug-ins/twain/tw_local.h
index e76cf87..793b8f3 100644
--- a/plug-ins/twain/tw_local.h
+++ b/plug-ins/twain/tw_local.h
@@ -29,18 +29,22 @@
 
 /* Functions which the platform-independent code will call */
 
-TW_UINT16 callDSM(pTW_IDENTITY, pTW_IDENTITY,
-		  TW_UINT32, TW_UINT16,
-		  TW_UINT16, TW_MEMREF);
-
-int twainIsAvailable(void);
-void twainQuitApplication ();
-gboolean twainSetupCallback (pTW_SESSION twSession);
-
-TW_HANDLE twainAllocHandle(size_t size);
+TW_UINT16 callDSM (
+    pTW_IDENTITY,
+    pTW_IDENTITY,
+    TW_UINT32,
+    TW_UINT16,
+    TW_UINT16,
+    TW_MEMREF);
+
+int       twainIsAvailable (void);
+void      twainQuitApplication ();
+gboolean  twainSetupCallback (pTW_SESSION twSession);
+
+TW_HANDLE twainAllocHandle (size_t size);
 TW_MEMREF twainLockHandle (TW_HANDLE handle);
-void twainUnlockHandle (TW_HANDLE handle);
-void twainFreeHandle (TW_HANDLE handle);
+void      twainUnlockHandle (TW_HANDLE handle);
+void      twainFreeHandle (TW_HANDLE handle);
 
 int twainMain ();
 int scanImage ();
diff --git a/plug-ins/twain/tw_mac.c b/plug-ins/twain/tw_mac.c
index 796d28e..50067a0 100644
--- a/plug-ins/twain/tw_mac.c
+++ b/plug-ins/twain/tw_mac.c
@@ -35,12 +35,12 @@
 #include "tw_util.h"
 #include "tw_local.h"
 
-TW_UINT16 twainCallback(pTW_IDENTITY pOrigin,
-                         pTW_IDENTITY pDest,
-                         TW_UINT32    DG,
-                         TW_UINT16    DAT,
-                         TW_UINT16    MSG,
-                         TW_MEMREF    pData);
+TW_UINT16 twainCallback (pTW_IDENTITY pOrigin,
+    pTW_IDENTITY pDest,
+    TW_UINT32    DG,
+    TW_UINT16    DAT,
+    TW_UINT16    MSG,
+    TW_MEMREF    pData);
 extern pTW_SESSION initializeTwain ();
 
 
@@ -50,12 +50,13 @@ extern pTW_SESSION initializeTwain ();
  * Call the specified function on the data source manager.
  */
 TW_UINT16
-callDSM(pTW_IDENTITY pOrigin,
-	pTW_IDENTITY pDest,
-	TW_UINT32    DG,
-	TW_UINT16    DAT,
-	TW_UINT16    MSG,
-	TW_MEMREF    pData)
+callDSM (
+    pTW_IDENTITY pOrigin,
+    pTW_IDENTITY pDest,
+    TW_UINT32    DG,
+    TW_UINT16    DAT,
+    TW_UINT16    MSG,
+    TW_MEMREF    pData)
 {
   /* Call the function */
   return DSM_Entry (pOrigin, pDest, DG, DAT, MSG, pData);
@@ -67,15 +68,15 @@ callDSM(pTW_IDENTITY pOrigin,
  * Return boolean indicating whether TWAIN is available
  */
 int
-twainIsAvailable(void)
+twainIsAvailable (void)
 {
   return TRUE;
 }
 
 TW_HANDLE
-twainAllocHandle(size_t size)
+twainAllocHandle (size_t size)
 {
-	return NewHandle(size);
+  return NewHandle (size);
 }
 
 TW_MEMREF
@@ -101,13 +102,14 @@ twainSetupCallback (pTW_SESSION twSession)
 {
   TW_CALLBACK callback;
   /* We need to set up our callback to receive messages */
-  callback.CallBackProc = (TW_MEMREF)twainCallback;
-  callback.RefCon = (TW_UINT32)twSession;
+  callback.CallBackProc = (TW_MEMREF) twainCallback;
+  callback.RefCon = (TW_UINT32) twSession;
   callback.Message = 0;
   twSession->twRC = callDSM(APP_IDENTITY(twSession), NULL,
                             DG_CONTROL, DAT_CALLBACK, MSG_REGISTER_CALLBACK,
                             (TW_MEMREF) &callback);
-  if (twSession->twRC != TWRC_SUCCESS) {
+  if (twSession->twRC != TWRC_SUCCESS)
+  {
     LogMessage("Couldn't set callback function (retval %d)", (int)(twSession->twRC));
     return FALSE;
   }
@@ -120,7 +122,7 @@ twainSetupCallback (pTW_SESSION twSession)
  * Unload the TWAIN dynamic link library
  */
 int
-unloadTwainLibrary(pTW_SESSION twSession)
+unloadTwainLibrary (pTW_SESSION twSession)
 {
   /* We're statically linked; just clear the session */
   DS_IDENTITY(twSession)->Id = 0;
@@ -132,23 +134,24 @@ unloadTwainLibrary(pTW_SESSION twSession)
   return TRUE;
 }
 
-TW_UINT16 twainCallback(pTW_IDENTITY pOrigin,
-                        pTW_IDENTITY pDest,
-                        TW_UINT32    DG,
-                        TW_UINT16    DAT,
-                        TW_UINT16    MSG,
-                        TW_MEMREF    pData)
+TW_UINT16 twainCallback (
+    pTW_IDENTITY pOrigin,
+    pTW_IDENTITY pDest,
+    TW_UINT32    DG,
+    TW_UINT16    DAT,
+    TW_UINT16    MSG,
+    TW_MEMREF    pData)
 {
   pTW_SESSION twSession = (pTW_SESSION)(((TW_CALLBACK *)pData)->RefCon);
-  LogMessage("twainCallback! DG 0x%x, DAT 0x%x, MSG 0x%x\n",
-    (int)DG, (int)DAT, (int)MSG);
+  LogMessage ("twainCallback! DG 0x%x, DAT 0x%x, MSG 0x%x\n",
+      (int) DG, (int) DAT, (int) MSG);
   processTwainMessage (MSG, twSession);
   return TWRC_SUCCESS;
 }
 
 void twainQuitApplication ()
 {
-  QuitApplicationEventLoop();
+  QuitApplicationEventLoop ();
 }
 
 
@@ -192,8 +195,8 @@ static void twainSetupMacUI()
 
   /* Voodoo magic fix inspired by java_swt launcher */
   /* Without this the icon setting doesn't work about half the time. */
-  CGrafPtr p = BeginQDContextForApplicationDockTile();
-  EndQDContextForApplicationDockTile(p);
+  CGrafPtr p = BeginQDContextForApplicationDockTile ();
+  EndQDContextForApplicationDockTile (p);
 
   SetApplicationDockTileImage (icon);
 }
@@ -204,7 +207,7 @@ twainMain()
   EventLoopTimerRef timer;
   OSStatus err;
 
-  twainSetupMacUI();
+  twainSetupMacUI ();
 
   /* Ok, back to work! */
   initializeTwain ();
@@ -215,13 +218,13 @@ twainMain()
                                NewEventLoopTimerUPP (doGetImage),
                                NULL, &timer);
   if (err)
-    {
-      g_warning ("InstallEventLoopTimer returned error %d", (int)err);
-      g_message ("Something went horribly awry.");
-      return -1;
-    }
+  {
+    g_warning ("InstallEventLoopTimer returned error %d", (int)err);
+    g_message ("Something went horribly awry.");
+    return -1;
+  }
 
-  RunApplicationEventLoop();
+  RunApplicationEventLoop ();
   return 0;
 }
 
diff --git a/plug-ins/twain/tw_platform.h b/plug-ins/twain/tw_platform.h
index 7ffce44..9cce4d8 100644
--- a/plug-ins/twain/tw_platform.h
+++ b/plug-ins/twain/tw_platform.h
@@ -23,11 +23,10 @@
  */
 
 #ifndef _TW_PLATFORM_H
-#define _TW_PLATFORM_H
+  #define _TW_PLATFORM_H
 
-#ifdef __APPLE__
-
-/* Mac OS X */
+  #ifdef __APPLE__
+    /* Mac OS X */
 
 #include <Carbon/Carbon.h>
 #include <TWAIN/TWAIN.h>
@@ -37,11 +36,9 @@
 #define DUMP_NAME "dtwain"
 #define READDUMP_NAME "rtwain"
 
-#define _stricmp strcasecmp
-
-#else
-
-/* Win32 */
+    #define _stricmp strcasecmp
+  #else
+    /* Win32 */
 
 #include <windows.h>
 #include "twain.h"
@@ -53,9 +50,8 @@
 #define DUMP_NAME "DTWAIN.EXE"
 #define READDUMP_NAME "RTWAIN.EXE"
 
-/* Windows uses separate entry point */
-#define TWAIN_ALTERNATE_MAIN
-
-#endif
+    /* Windows uses separate entry point */
+    #define TWAIN_ALTERNATE_MAIN
+  #endif /* __APPLE__ */
 
 #endif
diff --git a/plug-ins/twain/tw_util.c b/plug-ins/twain/tw_util.c
index 4d4ce2b..43ee831 100644
--- a/plug-ins/twain/tw_util.c
+++ b/plug-ins/twain/tw_util.c
@@ -82,7 +82,7 @@ FILE *logFile = NULL;
  * LogMessage
  */
 void
-LogMessage(char *format, ...)
+LogMessage (char *format, ...)
 {
   va_list args;
   time_t time_of_day;
@@ -92,15 +92,16 @@ LogMessage(char *format, ...)
   if (!logFile)
     logFile = g_fopen(DEBUG_LOGFILE, "w");
 
-  time_of_day = time(NULL);
-  ctime_string = ctime(&time_of_day);
+  time_of_day = time (NULL);
+  ctime_string = ctime (&time_of_day);
   ctime_string[19] = '\0';
 
-  fprintf(logFile, "[%s] ", (ctime_string + 11));
-  va_start(args, format);
-  vfprintf(logFile, format, args);
-  fflush(logFile);
-  va_end(args);
+  fprintf (logFile, "[%s] ", (ctime_string + 11));
+
+  va_start (args, format);
+  vfprintf (logFile, format, args);
+  fflush (logFile);
+  va_end (args);
 }
 
 void
diff --git a/plug-ins/twain/tw_win.c b/plug-ins/twain/tw_win.c
index 43d5d9d..80ee384 100644
--- a/plug-ins/twain/tw_win.c
+++ b/plug-ins/twain/tw_win.c
@@ -35,10 +35,10 @@
 #include "tw_util.h"
 #include "tw_local.h"
 
-LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
+LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
 
-int twainMessageLoop(pTW_SESSION);
-int TwainProcessMessage(LPMSG lpMsg, pTW_SESSION twSession);
+int twainMessageLoop (pTW_SESSION);
+int TwainProcessMessage (LPMSG lpMsg, pTW_SESSION twSession);
 
 extern GimpPlugInInfo PLUG_IN_INFO;
 extern pTW_SESSION initializeTwain ();
@@ -52,28 +52,28 @@ extern void setRunMode(char *argv[]);
 #define WM_TRANSFER_IMAGE (WM_USER + 100)
 
 /* main bits */
-static HWND        hwnd = NULL;
-static HINSTANCE   hInst = NULL;
+static HWND         hwnd  = NULL;
+static HINSTANCE    hInst = NULL;
 
 /* Storage for the DLL handle */
-static HINSTANCE hDLL = NULL;
+static HINSTANCE    hDLL  = NULL;
 
 /* Storage for the entry point into the DSM */
 static DSMENTRYPROC dsmEntryPoint = NULL;
 
-
 /*
  * callDSM
  *
  * Call the specified function on the data source manager.
  */
 TW_UINT16
-callDSM(pTW_IDENTITY pOrigin,
-	pTW_IDENTITY pDest,
-	TW_UINT32    DG,
-	TW_UINT16    DAT,
-	TW_UINT16    MSG,
-	TW_MEMREF    pData)
+callDSM (
+    pTW_IDENTITY pOrigin,
+    pTW_IDENTITY pDest,
+    TW_UINT32    DG,
+    TW_UINT16    DAT,
+    TW_UINT16    MSG,
+    TW_MEMREF    pData)
 {
   /* Call the function */
   return (*dsmEntryPoint) (pOrigin, pDest, DG, DAT, MSG, pData);
@@ -85,20 +85,21 @@ callDSM(pTW_IDENTITY pOrigin,
  * Return boolean indicating whether TWAIN is available
  */
 int
-twainIsAvailable(void)
+twainIsAvailable (void)
 {
   /* Already loaded? */
-  if (dsmEntryPoint) {
+  if (dsmEntryPoint)
+  {
     return TRUE;
   }
 
   /* Attempt to load the library */
-  hDLL = LoadLibrary(TWAIN_DLL_NAME);
+  hDLL = LoadLibrary (TWAIN_DLL_NAME);
   if (hDLL == NULL)
     return FALSE;
 
   /* Look up the entry point for use */
-  dsmEntryPoint = (DSMENTRYPROC) GetProcAddress(hDLL, "DSM_Entry");
+  dsmEntryPoint = (DSMENTRYPROC) GetProcAddress (hDLL, "DSM_Entry");
   if (dsmEntryPoint == NULL)
     return FALSE;
 
@@ -108,7 +109,7 @@ twainIsAvailable(void)
 TW_HANDLE
 twainAllocHandle (size_t size)
 {
-  return GlobalAlloc(GHND, size);
+  return GlobalAlloc (GHND, size);
 }
 
 TW_MEMREF
@@ -142,11 +143,12 @@ twainSetupCallback (pTW_SESSION twSession)
  * Unload the TWAIN dynamic link library
  */
 int
-unloadTwainLibrary(pTW_SESSION twSession)
+unloadTwainLibrary (pTW_SESSION twSession)
 {
   /* Explicitly free the SM library */
-  if (hDLL) {
-    FreeLibrary(hDLL);
+  if (hDLL)
+  {
+    FreeLibrary (hDLL);
     hDLL=NULL;
   }
 
@@ -170,32 +172,34 @@ unloadTwainLibrary(pTW_SESSION twSession)
  * Returns FALSE if the application should skip processing of this message
  */
 int
-TwainProcessMessage(LPMSG lpMsg, pTW_SESSION twSession)
+TwainProcessMessage (LPMSG lpMsg, pTW_SESSION twSession)
 {
-  TW_EVENT   twEvent;
+  TW_EVENT twEvent;
 
   twSession->twRC = TWRC_NOTDSEVENT;
 
   /* Only ask Source Manager to process event if there is a Source connected. */
-  if (DSM_IS_OPEN(twSession) && DS_IS_OPEN(twSession)) {
-		/*
-		 * A Source provides a modeless dialog box as its user interface.
-		 * The following call relays Windows messages down to the Source's
-		 * UI that were intended for its dialog box.  It also retrieves TWAIN
-		 * messages sent from the Source to our Application.
-		 */
-		twEvent.pEvent = (TW_MEMREF) lpMsg;
+  if (DSM_IS_OPEN(twSession) && DS_IS_OPEN(twSession))
+  {
+    /*
+     * A Source provides a modeless dialog box as its user interface.
+     * The following call relays Windows messages down to the Source's
+     * UI that were intended for its dialog box.  It also retrieves TWAIN
+     * messages sent from the Source to our Application.
+     */
+    twEvent.pEvent = (TW_MEMREF) lpMsg;
 		twSession->twRC = callDSM(APP_IDENTITY(twSession), DS_IDENTITY(twSession),
 			DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT,
 			(TW_MEMREF) &twEvent);
 
-		/* Check the return code */
-		if (twSession->twRC == TWRC_NOTDSEVENT) {
-			return FALSE;
-		}
+    /* Check the return code */
+    if (twSession->twRC == TWRC_NOTDSEVENT)
+    {
+      return FALSE;
+    }
 
-		/* Process the message as necessary */
-		processTwainMessage(twEvent.TWMessage, twSession);
+    /* Process the message as necessary */
+    processTwainMessage (twEvent.TWMessage, twSession);
   }
 
   /* tell the caller what happened */
@@ -210,14 +214,16 @@ TwainProcessMessage(LPMSG lpMsg, pTW_SESSION twSession)
  * the application exits.
  */
 int
-twainMessageLoop(pTW_SESSION twSession)
+twainMessageLoop (pTW_SESSION twSession)
 {
   MSG msg;
 
-  while (GetMessage(&msg, NULL, 0, 0)) {
-    if (DS_IS_CLOSED(twSession) || !TwainProcessMessage(&msg, twSession)) {
-      TranslateMessage((LPMSG)&msg);
-      DispatchMessage(&msg);
+  while (GetMessage(&msg, NULL, 0, 0))
+  {
+    if (DS_IS_CLOSED(twSession) || !TwainProcessMessage (&msg, twSession))
+    {
+      TranslateMessage ((LPMSG) &msg);
+      DispatchMessage (&msg);
     }
   }
 
@@ -231,29 +237,30 @@ twainMessageLoop(pTW_SESSION twSession)
  * GetLastError.
  */
 void
-LogLastWinError(void)
+LogLastWinError (void)
 {
-	LPVOID lpMsgBuf;
-
-	FormatMessage(
-		FORMAT_MESSAGE_ALLOCATE_BUFFER |
-		FORMAT_MESSAGE_FROM_SYSTEM |
-		FORMAT_MESSAGE_IGNORE_INSERTS,
-		NULL,
-		GetLastError(),
-		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
-		(LPTSTR) &lpMsgBuf,
-		0,
-		NULL
-		);
+  LPVOID lpMsgBuf;
+
+  FormatMessage (
+      FORMAT_MESSAGE_ALLOCATE_BUFFER |
+      FORMAT_MESSAGE_FROM_SYSTEM |
+      FORMAT_MESSAGE_IGNORE_INSERTS,
+      NULL,
+      GetLastError (),
+      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
+      (LPTSTR) &lpMsgBuf,
+      0,
+      NULL
+  );
 
 	LogMessage("%s\n", lpMsgBuf);
 
-	/* Free the buffer. */
-	LocalFree( lpMsgBuf );
+  /* Free the buffer. */
+  LocalFree ( lpMsgBuf );
 }
 
-void twainQuitApplication ()
+void
+twainQuitApplication ()
 {
   PostQuitMessage (0);
 }
@@ -273,10 +280,11 @@ void twainQuitApplication ()
  * datasource.
  */
 int APIENTRY
-WinMain(HINSTANCE hInstance,
-	HINSTANCE hPrevInstance,
-	LPSTR     lpCmdLine,
-	int       nCmdShow)
+WinMain (
+    HINSTANCE hInstance,
+    HINSTANCE hPrevInstance,
+    LPSTR     lpCmdLine,
+    int       nCmdShow)
 {
 
   /*
@@ -301,7 +309,7 @@ WinMain(HINSTANCE hInstance,
    * Now, call gimp_main... This is what the MAIN() macro
    * would usually do.
    */
-  return gimp_main(&PLUG_IN_INFO, __argc, __argv);
+  return gimp_main (&PLUG_IN_INFO, __argc, __argv);
 }
 
 /*
@@ -309,7 +317,8 @@ WinMain(HINSTANCE hInstance,
  *
  * allow to build as console app as well
  */
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
 {
 #ifdef _DEBUG
   /* When in debug version, we allow different run modes...
@@ -322,7 +331,7 @@ int main (int argc, char *argv[])
    * Now, call gimp_main... This is what the MAIN() macro
    * would usually do.
    */
-  return gimp_main(&PLUG_IN_INFO, __argc, __argv);
+  return gimp_main (&PLUG_IN_INFO, __argc, __argv);
 }
 
 /*
@@ -331,7 +340,7 @@ int main (int argc, char *argv[])
  * Initialize window data and register the window class
  */
 BOOL
-InitApplication(HINSTANCE hInstance)
+InitApplication (HINSTANCE hInstance)
 {
   WNDCLASS wc;
   BOOL retValue;
@@ -345,18 +354,18 @@ InitApplication(HINSTANCE hInstance)
   wc.cbClsExtra = 0;
   wc.cbWndExtra = 0;
   wc.hInstance = hInstance;
-  wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
-  wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+  wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
+  wc.hCursor = LoadCursor (NULL, IDC_ARROW);
   wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
   wc.lpszClassName = APP_NAME;
   wc.lpszMenuName = NULL;
 
   /* Register the window class and stash success/failure code. */
-  retValue = RegisterClass(&wc);
+  retValue = RegisterClass (&wc);
 
   /* Log error */
   if (!retValue)
-    LogLastWinError();
+    LogLastWinError ();
 
   return retValue;
 }
@@ -368,27 +377,29 @@ InitApplication(HINSTANCE hInstance)
  * interface with the TWAIN datasource.
  */
 BOOL
-InitInstance(HINSTANCE hInstance, int nCmdShow, pTW_SESSION twSession)
+InitInstance (HINSTANCE hInstance, int nCmdShow, pTW_SESSION twSession)
 {
   /* Create our window */
-  hwnd = CreateWindow(APP_NAME, APP_NAME, WS_OVERLAPPEDWINDOW,
-		      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
-		      NULL, NULL, hInstance, NULL);
+  hwnd = CreateWindow (APP_NAME, APP_NAME, WS_OVERLAPPEDWINDOW,
+      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
+      NULL, NULL, hInstance, NULL);
 
-  if (!hwnd) {
+  if (!hwnd)
+  {
     return (FALSE);
   }
 
   /* Register our window handle with the TWAIN
    * support.
    */
-  registerWindowHandle(twSession, hwnd);
+  registerWindowHandle (twSession, hwnd);
 
   /* Schedule the image transfer by posting a message */
-  PostMessage(hwnd, WM_TRANSFER_IMAGE, 0, 0);
+  PostMessage (hwnd, WM_TRANSFER_IMAGE, 0, 0);
+
+  ShowWindow (hwnd, nCmdShow);
 
-  ShowWindow(hwnd, nCmdShow);
-  UpdateWindow(hwnd);
+  UpdateWindow (hwnd);
 
   return TRUE;
 }
@@ -403,17 +414,17 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, pTW_SESSION twSession)
  * operate.
  */
 int
-twainMain()
+twainMain ()
 {
   /* Initialize the twain information */
   pTW_SESSION twSession = initializeTwain();
 
   /* Perform instance initialization */
-  if (!InitApplication(hInst))
+  if (!InitApplication (hInst))
     return (FALSE);
 
   /* Perform application initialization */
-  if (!InitInstance(hInst, SHOW_WINDOW, twSession))
+  if (!InitInstance (hInst, SHOW_WINDOW, twSession))
     return (FALSE);
 
   /*
@@ -421,7 +432,7 @@ twainMain()
    * This call will not return until the application
    * exits.
    */
-  return twainMessageLoop(twSession);
+  return twainMessageLoop (twSession);
 }
 
 /*
@@ -430,23 +441,24 @@ twainMain()
  * Process window message for the main window.
  */
 LRESULT CALLBACK
-WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
-  switch (message) {
-
-  case WM_TRANSFER_IMAGE:
-    /* Get an image */
-    scanImage ();
-    break;
-
-  case WM_DESTROY:
-    LogMessage("Exiting application\n");
-    PostQuitMessage(0);
-    break;
-
-  default:
-    return (DefWindowProc(hWnd, message, wParam, lParam));
+  switch (message)
+  {
+    case WM_TRANSFER_IMAGE:
+      /* Get an image */
+      scanImage ();
+      break;
+
+    case WM_DESTROY:
+      LogMessage("Exiting application\n");
+      PostQuitMessage (0);
+      break;
+
+    default:
+      return (DefWindowProc (hWnd, message, wParam, lParam));
   }
+
   return 0;
 }
 
