some bugs fixed for integration