-- applied patch and made some modifications

Applied patch and made some modification. Also fixed one test.