Improved bridge. Fixed I/O problem in function template