some corrections and changes for coding style