Minor modifications to original source code for integration purposes.